【发布时间】:2010-11-07 23:21:32
【问题描述】:
我正在创建一个常见问题解答页面,通过单击问题来切换答案。问题是h3,答案是几个p-elements。像这样:
<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>
如何切换属于某个问题的所有p-元素?我的 JS 在页面上切换所有以下p-elements:
$(document).ready(function(){
$("p").hide();
$("h3").click(function(){
$(this).nextAll("p").toggle();
});
});
我不能使用div 的或类)。
【问题讨论】:
标签: javascript jquery toggle next