i have the following simple code, but it doesn,t work
<ul>
<li id="one" onmouseover="this.style.background-color='white';">
<a href="#">home</a>
</li>
</ul>
could you tell me why.
thanks
edit:
and how can i also change the color of a tag, onmouseover of li
Convert hyphens to camelCase when changing properties of the style object in JS.
backgroundColorHowever, you are trying to solve this problem in the wrong way.
If you really wanted to style the list item on hover, then you probably should be using
li:hoverin your stylesheet. The only downside is that this won’t work in IE 6 (although it is just a cosmetic effect on an ancient browser that is increasingly falling in the “Not supported” box).That said, having a hover effect shouts “You can click now!” at the user — but only the link portion of the list item will do anything when clicked. This means that you should style the
aelement, not theli… but style it to fill the list item (and this will work in IE6).Listamatic has many examples.