html - Is there an efficient way of doing jQuery toggle? -
I was creating an FAQ section for my site and, thinking that the answer to the question There is a more efficient way to answer for giving. Clicked. So far, I have the code below, however, when any question is clicked, all this answer opens. If I want to do it one by one, then I have 100 questions, and write 100 line toggle for answer -1, answer-2 ... So, is this the solution? (Function () {$ ("p.answer"). Toggle ("slow");}
$ (function () {$ ("a.question"). ;}); HTML + CSS:
a.question {display: block} p {display: none} & lt; A class = "question" & gt; Question 1 & lt ;? / A & gt; & Lt; P class = "answer" & gt; Answer 1 & lt; / P & gt; & Lt; One class = "question" & gt; Question 2? & Lt; / A & gt; & Lt; P class = "answer" & gt; Answer 2 & lt; / P & gt; & Lt; One class = "question" & gt; Question 3? & Lt; / A & gt; & Lt; P class = "answer" & gt; Answer 3 & lt; / P & gt;
$ (function () {$ ("a.question") Click (function () {$ (this) .next ("p.answer") toggle ("slow");});});
Comments
Post a Comment