How to remove a CSS attribute with jQuery?


In jQuery, you can add an attribute to an element via the attr function. It is also possible to remove an attribute through the removeAttr function.

And when I set a css attribute through the $.css function? How do I remove?


The simplest solution would be to reset the element:

$.css("background-color", ""); // exemplo com background-color


  var contador = 0;
    if(contador == 0)
      $(this).css("background-color", "blue");
      contador = 1;
      $(this).css("background-color", "");
      contador = 0;
<script src=""></script>

<button class="btn">Exemplo</button>

Fonte: StackOverflow

Scroll to Top