0
I have 2 show/hide buttons from 2 groups: group1 and Group2.When I click to open the group1, for example, it opens a card with information from that group and when I click hide it hides.
So far so good!
What I want is that when I click on the other group (Grupo2), instead of opening Grupo2 below what was already open(group1), I want to click it to close the group 1 to open the new.
<button type="button" class=" grupo1 btn-toggle btn waves-effect waves-light green" data-element="#grupo1">
Mostrar / Esconder
</button>
<button type="button" class=" grupo2 btn-toggle btn waves-effect waves-light green" data-element="#grupo2">
Mostrar / Esconder
</button>
<div class="grupos row">
<div class="col s12 m6 l3" id="grupo1" style="display:none">
<div class="card">
<div class="card-content green darken-2 white-text">
</div>
</div> </div> </div>
<div class="grupos row">
<div class="col s12 m6 l3" id="grupo2" style="display:none">
<div class="card">
<div class="card-content green darken-2 white-text">
</div>
</div> </div> </div>
// Função do button Mostrar/Esconder do card
$(function(){
$(".btn-toggle").click(function(e){
e.preventDefault();
el = $(this).data('element');
$(el).toggle();
});
});
Thank you Caique! That’s exactly what I needed!!
– Bianca C.