Javascript active state with different colors

blg

New Member
I would like to make a nav menu with three different colors for the selected state - one for each menu item.I'v searched everywhere, but all I found was this code, with only one selected state.This is my code:\[code\]<html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css"> .one{ background-color:none; color:black;} .one_active a { color:red;} .two_active a { color:yellow;} .three_active a { color:#e3e3e3;}</style><script type="text/javascript"> var divSelected = null; function SelectOrUnSelect(a) { if (divSelected != null) divSelected.className = 'one'; divSelected = document.getElementById(a); document.getElementById(a).className = 'one_active'; } </script></head><body> <ul> <li class="one" id="t1"><a href="http://stackoverflow.com/questions/15739031/#1" onclick="SelectOrUnSelect('t1')">one</a></li> <li class="two" id="t2"><a href="http://stackoverflow.com/questions/15739031/#2" onclick="SelectOrUnSelect('t2')">two</a></li> <li class="three" id="t3"><a href="http://stackoverflow.com/questions/15739031/#3" onclick="SelectOrUnSelect('t3')">three</a></li> </ul></body></html>\[/code\]
 
Back
Top