Log in

View Full Version : Changing bg-color of Menu's on clicking



ahi
07-25-2007, 06:50 PM
Hi,

I'm looking for a CSS/JavaScript solution for changing the color of a menu item on clicking.

I already have a menu created using CSS.

It is displayed in a DIV with "a:hover" style defining what color the menu item should be displayed in, when the "mouse over" event occurs.

Now, I want the color of the menu item to change when the user selects that menu item. I cannot use a:visited, because each menu item displays a different page, and ONLY the menu item selected, must display YELLOW background to indicate that the user is on that page. Any generic CSS/JavaScript code will be greatly appreciated.

Thanks
Ahi

thetestingsite
07-25-2007, 06:55 PM
You could make a class called 'current', then use the following for the css:




.current {
background-color: yellow; /* the background color */
color: black; /* the font color */
}


then for the html in the menu (sample, not exactly your menu because you did not post the code for it):



<div class="current">


Place that for the link that corresponds to the page that it references.

Hope this helps.