Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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>
- ul#leftlist li.current a {
- color: rgb(96,176,255) !important;
- background-color:218,218,218) !important;
- }
- ul#leftlist li#current a{color: rgb(96,176,255); background-color:218,218,218);}
- ul#leftlist li#current a{color: rgb(96,176,255); background-color: rgb(218,218,218);}
- liArray=element.parentNode.getElementsByTagName("li");
- function myFunction(element){
- var liArray = document.getElementById("leftlist").childNodes;
- var i=0, item;
- while (item = liArray[i++]) {
- if (item.nodeType === 1) {
- item.className = item.className.replace(/(^| )current( |$)/g, '');
- }
- }
- element.className += " current";
- }
- ul#leftlist li.current a { ... }
Add Comment
Please, Sign In to add comment