1

Basically i just want to have padding to the left and not all around on this code:

if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
  document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
  document.getElementById("livesearch").style.border="1px solid #000";
  document.getElementById("livesearch").style.background="#FFF";
  document.getElementById("livesearch").style.padding-left="10px";    
}

But i don't know the syntax as padding-left breaks the argument. Is there a better way to do this without using a CSS as there are different styles depending on the if/else statements?

4 Answers 4

3

In native js you want paddingLeft not padding left

document.getElementById("livesearch").style.paddingLeft="10px"; 
Sign up to request clarification or add additional context in comments.

Comments

3

Try this: document.getElementById("livesearch").style.paddingLeft="10px";

Comments

1

its always good to catch your variables on top as well,

var liveSearch = document.getElementById("livesearch")
liveSearch.style.paddingLeft = "10px";

Comments

0

There's a reference that explains which javasceript term corresponds to which css. like this This page

But generally its a good practice to use css whenever possible. This separation between javascript and css is recommended.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.