How to remove css property in jQuery

You can remove them by:

$(".icha0").css({ 'background-color' : '', 'opacity' : '' });

You can use .css() to remove css property as well, like this:

$(".icha0").css("background-color","");
$(".icha0").css("opacity","");

As mentioned in the jquery documentation:

Setting the value of a style property to an empty string — e.g. $('#mydiv').css('color', '') — removes that property from an element if it has already been directly applied,


To remove the in-line CSS property use:

$('.className').css({propertyName: ''});

To remove the whole in-line style of an element use:

$('.className').removeAttr('style');

I've also found this suggestion to remove the CSS property from styles (separate file) use:

$('.className').style.propertyName = '';

BUT I couldn't get it to work at all, so I'm putting it here just FYI.


Either you can set the properties back to blank:

$(".icha0").css("background-color","");

Or you can change the code to use classes defined in a CSS file:

$(".icha0").addClass('properties'); 
$(".icha0").removeClass('properties');

I was having this problem but I have not seen any solution here that satisfies the OP. Most of the solutions suggest getting rid of the entire style attribute which is not worth it.

I used jQuery's prop method.

var styleObject = $('my-selector').prop('style'); 

styleObject.removeProperty('background-color');