July 13, 2012
Active menu background color
Question by user1522624
I have a vertical menu. It is .glossymenu . The menu item is accessed using css as .glossymenu a.menuitem . I want to change the background color when the menu item is selected or when the menu item is active. I am trying to use the following JQuery:
$(".glossymenu a.menuitem").click(function(){
$(this).siblings(".active").removeClass("active");
$(this).addClass("active");
});
But, I am unable to resolve my issue using this. Any ideas, how to change the background color of the menu item, when it is selected. It should not change when we click outside the menu item in blank area, when the menu is active.
Thanks,
Prasad
Answer by Starx
Active state is available in CSS and it much better to use that one instead.
a.menuitem:active { background-color: #c00; }