Reputation: 5
We have jquery menu in application, and on selecting of particular element; its background color gets change.
Color is changing according to css. We are designing "Theme" and are trying to change color of css dynamically using Javascript, so that on selecting menu; its color will be changed. But, we are not getting well way to do it.
Following is the css: -
.mmenu li.mmenu-selected > a
{
background: #1971AA;
color:#FFFFFF;
font-weight: normal;
}
Upvotes: 1
Views: 1099
Reputation: 3299
Try css method:
$(".mmenu li.mmenu-selected > a").css({"background": "#1971AA", "color":"#FFFFFF"});
Upvotes: 0
Reputation: 167240
If you have a fixed number of values for the background, then use classes like this:
.theme1 .mmenu li.mmenu-selected > a {background-color: #f99;}
.theme2 .mmenu li.mmenu-selected > a {background-color: #ff9;}
.theme3 .mmenu li.mmenu-selected > a {background-color: #fff;}
If not, use inline styles, targetting the parent and giving an inherit
:
$(".mmenu").css("background-color", "#ff9");
And in the CSS:
.mmenu li.mmenu-selected > a {background-color: inherit;}
Upvotes: 1