3
In the JQuery
, we have a function called toggle
which allows us to switch between the element being visible or not. And the function toggleClass
, which toggles between whether or not to include a class.
$(function () {
$('button').click(function () {
$('div').toggle();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div style="display:none">Estou aqui</div>
<button>Click</button>
But I need to "put and take out" an attribute in the same way that this function does. I want to do this with the attribute required
in a input
.
You can do it in jQuery?
Pènsei right there, boss, but in a way that would work for any attribute. Anyway +1 ;)
– Wallace Maxters
@Wallacedesouza already corrected... because it is ... for me win upvotes guys come by wagon (this when I win, because it turned rarity), to me Win downvote the guys see rocket...
– Guilherme Nascimento
They took and put the vote (strip and put several times). I think someone is joking because the question is just about toggle. Rsrsrsrsrsrs
– Wallace Maxters
@Wallacedesouza was a jQuery extension called
toggleHater.js
, works like this$("@guilhermenascimento").toggleHater();
– Guilherme Nascimento