I was making a section with questions and answers, and want them to be hidden, till a user clicks on the relevant part of the section. This is very similar to the question asked here :
jquery Simple SlideToggle in sections
However, i have multiple ques开发者_运维知识库tions in a section, flow being like :
All questions and answers are hidden. When someone clicks on a section, all the relevant questions in that section open up and when one clicks on the question, it's answer gets displayed.
When I click on another question, the previous open answer hides. and the relavent answer opens. When an answer opens and someone clicks on another section, that section opens up hiding up all the other sections.
How does one do this??
Here is a sample jsfiddle, if someone can help. http://jsfiddle.net/NpGMh/1/
Thanks.
Take a look at this fiddle. I think that's what you intended. I used the nextUntil
selector to get all siblings within that section up until the next section.
have you looked at the jquery ui accordian?
精彩评论