I’m trying to use javascript to change the color of a specific li of a ul, but my code is highlighting all subsequent li of the list. Here is the code:
<ul list style type = "none">
<li id = "l0">this is line one</li>
<li id = "l1">this is line two</li>
<li id = "l2">this is line three</li>
</ul>
function highlight(name,color) {
var a = document.getElementById(name);
a.style.color = color;
}
When I call this with something like
highlight("l0","orangered");
it changes the colors of “l0” through “l2”, instead of just “l0”. I would very much prefer a solution using only javascript, rather than a 3rd party library. Thanks!
I made a fiddle using your js function:
http://jsfiddle.net/Ahb8F/
It works fine, did you expect/want something else?