jQuery - remove background-color when an element is visible

didi picture didi · Nov 18, 2013 · Viewed 36.1k times · Source

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;

Answer

Charlie74 picture Charlie74 · Nov 18, 2013

I believe you want something like this...

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

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