0
I need it as soon as a div is clicked (.titulo
), display another div
that’s inside of her (.answer
).
I learned to do using the Jquery method classToggle
, as soon as the div
is clicked adds class hide
, whose the same in the CSS code displays it.
But I need to do it for several div
equal, only when I click on one it displays all the others and I I want it to show only what was clicked...
Code:
$(document).ready(function() {
$(".titulo").click(function() {
$(".answer").toggleClass("hide");
});
});
.hide {
opacity: 0;
visibility: hidden;
height: 35px;
margin-top: -70px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<article class="question">
<header>
<div class="titulo">
<h3 class="tittle faq">Como formatar / passar imagem?</h3>
<img src="Imagens/mais.png" class="pam">
</div></header>
<div class="answer hide">
<p>"TEXTO".</p>
</div>
</article>
<article class="question">
<header>
<div class="titulo">
<h3 class="tittle faq">Como trocar cartucho da impressora?</h3>
<img src="Imagens/mais.png" class="pam">
</div>
</header>
<div class="answer hide">
<p>"TEXTO".</p>
</div>
</article>
Buddy, thanks for the answer. I am beginner in the area and am just venturing to learn more... If you have a better solution (redo the code), tell me there po... Keep only for you don’t hehehe
– Adriel Almeida
@Adrielalmeida Glad you could help! I really hope you contributed with your learning. About redoing the code, that’s not the focus of your question. And another, the community doesn’t usually take this kind of question well. I think you have an appropriate Exchange platform community for "improve code" questions. Also, if you have any problems or questions specific, here will be the right place to ask. Ahhh, if my answer solved your problem, remember to mark later. Hug.
– LipESprY