0
Guys, I have a Jquery, JS problem I have a set of buttons with the initials of each name, I would like to make them appear with your Ivs when clicking and when click on another disappear the previous one and appear only the other, I have already managed to make it appear by clicking, but it will appear as I click on the others
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
@foreach($letras as $letra)
<div class="btn-group mr-2" role="group" aria-label="First group">
<button data-letra="{{$letra->letra}}" type="button" class="btn btn-secondary showDiv">{{$letra->letra}}</button>
</div>
@endforeach
</div>
@foreach($exames as $key => $exame)
<div class="list-group space" style="display: none" id="{{$key}}">
@foreach($exame as $exameAux)
<div id="accordion" role="tablist" aria-multiselectable="true">
<div class="card">
<div style="background-color:#f7f7f9 !important" class="card-header" role="tab" id="headingOne">
<h5 class="mb-0">
<a class="collapse-icon" data-toggle="collapse" data-parent="#accordion" href="#{{ $exameAux->id }}" aria-expanded="true" aria-controls="collapseOne">
<i style="color:#0a5f55;" class="fa fa-plus"></i>
{{ $exameAux->exame }}
</a>
</h5>
</div>
<div id="{{ $exameAux->id }}" class="collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="card-body">
<p><strong>Material</strong>: {{ $exameAux->material }}</p>
<p><strong>Tempo em Jejum</strong>: {{ $exameAux->tempo_jejum }}</p>
<p><strong>Observações</strong>: {{ $exameAux->obs }}</p>
</div>
</div>
</div>
</div>
@endforeach
</div>
@endforeach
His JS is like this
<script type="text/javascript">
$(".showDiv").click(function(){
var letra = $(this).data('letra');
$("#" + letra).fadeIn();
});
</script>
Thanks, I tested it this way and it worked.
– Linton Junior