21
In jQuery, it is possible to add an attribute to an element through the function attr
. You can also remove an attribute through the function removeAttr
.
And when I define an attribute of css
through function $.css
? How do I remove?
21
In jQuery, it is possible to add an attribute to an element through the function attr
. You can also remove an attribute through the function removeAttr
.
And when I define an attribute of css
through function $.css
? How do I remove?
24
The simplest solution would be to reset the element:
$.css("background-color", ""); // exemplo com background-color
Example:
$(function(){
var contador = 0;
$(".btn").click(function(){
if(contador == 0)
{
$(this).css("background-color", "blue");
contador = 1;
}
else
{
$(this).css("background-color", "");
contador = 0;
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="btn">Exemplo</button>
Source: Stackoverflow
13
Remove a CSS attribute:
$(el).css("color", "");
Remove multiple CSS attributes:
$(el).css({
"color": "",
"background-color": "",
"outline": "",
});
I found this interesting, huh
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.
Related to the OS, hehe
– Guilherme Lautert
Yes, yes I was putting in the answer along with the example kk
– Leonardo
Thank you. Someone will benefit from this :D
– Wallace Maxters