Trying to obtain attriubute of an li element set with css

T

Terry

Hi folks.

I was wondering why it seems that I can't obtain the properties that
have to been assigned to a tag through use of css.


For example if I have:


css:


#theli {
display:inline;
background-color: green;
padding-left:10px;
padding-right:10px;



}


html:

<li id="theli">Hi there</li>


And I have in a javascript function that is called when the page is
loaded:


alert("color = " +
document.getElementById("theli").style.backgroundColor);
document.getElementById("theli").style.backgroundColor = "black";
alert("color = " +
document.getElementById("theli").style.backgroundColor);


The first alert only shows color = (with nothing else)


while the second alert shows color = black


Any ideas as to why I don't see green at the end of the first
color: ?


the url to my page is http://restaurant.atwebpages.com/contactus.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top