Hi, i'm creating an FAQ page where the answer is toggled by clicking on the question. The question is h3 and the answer is several "p" elements. Like this:
<h3>The First Question</h3>
<p>Answer Paragraph</p>
<p>Answer Paragraph</p>
<p>Answer Paragraph</p>
<h3>The Second Question</h3>
<p>Answer Paragraph</p>
<p>Answer Paragraph</p>
How can I toggle all p elements belonging to a certain question? My JS toggles ALL following p elements on the page:
$(document).ready(function(){
$("p").hide();
$("h3").click(function(){
$(this).nextAll("p").toggle();
});
});
(I cannot use div's or classes). Thank you for any help!