Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - remove background-color when an element is visible

I would like to remove the background-color (only the background-color) of the menu once another element is visible. I wrote this code, but it doesn't work - anybody can help?

$(function() {
if($("#wrapperHome").is(":visible")) {
    $("#menu a").css({ "background-color", "black" });  
}
});

The menu has this background style sheet information.

background:url(img/official/menu.png) center center no-repeat #f2f2f7;
like image 709
didi Avatar asked Nov 18 '13 18:11

didi


2 Answers

I believe you want something like this...

$("#menu a").css("background-color", ""); 

Setting the background-color to "" essentially removes the styling, removing the color.

like image 181
Charlie74 Avatar answered Nov 05 '22 20:11

Charlie74


Use : not , when doing key/val CSS changes:

$("#menu a").css({ "background-color" : "black" }); 

Or since it's one value:

$("#menu a").css("background-color", "black"); 
like image 3
tymeJV Avatar answered Nov 05 '22 20:11

tymeJV