My predicament is fairly simple: this function gets the id
of 'this' <li>
element based on parent id
of <ul>
. It used to work fine but not any more, I will either need to have <ul>
use class
es instead of id
while still being able to assign id
of 'current' to the current element, or change my css
function myFunction(element){
liArray = document.getElementById("leftlist").childNodes;
i=0;
while(liArray[i]){
liArray[i].id="";
i++;
}
element.id="current"; // or element.className ?
}
/**** css *********/
ul#leftlist {background-color: rgb(205,205,205);}
ul#leftlist li#current a{color: rgb(96,176,255); background-color:218,218,218);}
ul#leftlist li a{ color: rgb(86,86,86);}
#leftlist a:link{color: rgb(86,86,86);background-color: #ddd;}
#leftlist a:active{color: rgb(96,176,255); background-color: rgb(218,218,218); }
/****** html *********/
<ul id="leftlist">
<li onClick='myFunction(this);'><a href="123" bla bla </a></li>
<li onClick='myFunction(this);'> .... etc.</li>
</ul>
Perhaps i need to change my css, this worked before but now the current id
is not being effective as ul#leftlist li a
takes priority even when i assign id="current"
via javascript.