[ACCEPTED]-How to change css property using jquery with this code-css

Accepted answer
Score: 34

You can use the css method to change a CSS 6 property (or multiple properties if necessary):

$("#business").click(function(event){
    jQuery.fx.off = true;
    $("#businessmenu").toggle("");
    $(this).css("background-color", "#000");
    event.stopPropagation();
});
$('html').click(function() {
    $("#businessmenu").hide();
    $("#business").css("background-color", "#323232");
});

Note 5 that I've combined the 2 event listeners 4 you had bound to #business as it's makes no difference 3 to just bind the one.

As a side note, is 2 there a reason you are passing an empty 1 string to hide? That shouldn't be necessary.

Score: 4

If you want to change the background of 4 an element (in your case "#business") to 3 a color, you simply do:

$("#business").css({
     "background": "#000"
});

But I am not sure 2 what you mean by the "menu", you should 1 probably show us the code of your HTML!

Score: 1

The css function is used for changing CSS properties 1 like background.

$('html').click(function() {
  $('#businessmenu').hide("");
  $('#busniessmenu').css('background-color', '#323232');
});

$('#business').click(function(event){
  event.stopPropagation();
  $(this).css('background-color', '#000');
});

More Related questions