我正在使用 jQuery 设置一个非常简单的常见问题解答页面。像这样:
<h2>What happens when you click on this question?</h2>
<p>This answer will appear!</p>
这都在一个非常具体的 div 中,所以我将选择带有$('#faq h2')
. 很简单,对吧?单击 H2,然后使用this.next()
显示下一段。
(这个页面的警告是非程序员将维护它,这就是我不使用类的原因:不能保证任何新条目中都会有正确的类。)
所以!问题:
<h2>What happens when you click on the next question?</h2>
<p>That is an interesting conundrum.</p>
<p>Because the maintainer is kind of long-winded</p>
<p>and many answers will span a few paragraphs.</p>
那么,如何在不添加div
s 和 classes 以及诸如此类的情况下,让我的this.next()
例程选择问题-that-was-clicked-on 和下一个问题(H2 标题)之间的所有内容?