Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove css property in jQuery

Tags:

jquery

if(prev_clicked) {        $("#accordion li a.category").css('background-image', 'url("img/off_all_channel.png")');                         $("#accordion li a.comment").css('background-image', 'url("img/on_all_online.png")');                        $(".icha0").removeProperty("background-color");     $(".icha0").removeProperty("opacity"); } else {       $(".icha0").css("background-color","#D5D5D2");    $(".icha0").css("opacity","0.70"); } 

I am trying to remove two css properties that I added but It seems not working. Any though?

like image 756
SooIn Nam Avatar asked Feb 23 '12 01:02

SooIn Nam


People also ask

How to remove CSS property with jQuery?

2 different approaches to remove style inline CSS in jQuery. Use removeAttr() to remove all inline style attribute. Use CSS() to remove the specific CSS property.

How to remove CSS class in jQuery?

To remove all CSS classes of an element, we use removeClass() method. The removeClass() method is used to remove one or more class names from the selected element.

How to remove property jQuery?

The . removeProp() method removes properties set by the . prop() method. Note:This method should not be used to remove built-in (native) properties such as "checked", "disabled", "selected", or others.

How do I delete a property in CSS?

Use the style. removeProperty() method to remove CSS style properties from an element, e.g. box. style. removeProperty('background-color') .


1 Answers

You can remove them by:

$(".icha0").css({ 'background-color' : '', 'opacity' : '' }); 
like image 67
Nevin Avatar answered Sep 24 '22 20:09

Nevin