JSFiddle - React, Tailwind, and code Playground
HTML
<div class="questions-answer-block">
<p class="question">This is a Question?</p>
<p class="answer hideinit">Here is the Answer</p>
</div>
<div class="questions-answer-block">
<p class="question">This is a Question?</p>
<p class="answer hideinit">Here is the Answerdadawdawdawdawdawdawdawdwadawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawdawd</p>
</div>
CSS
.questions-answer-block {
text-align: left;
margin-left: 25px;
}
.questiaon {
cursor: pointer;
}
.hideinit {
display: none;
}
.display {
display: inline-block;
}
JavaScript
$(".question").click(function(argument) {
var el = $(this).parent().find(".answer");
if (el.hasClass("display")) {
el.removeClass("display").addClass("hideinit");
} else {
el.removeClass("hideinit").addClass("display");
}
});