我有一个带有自升式标记的常见问题解答,如下所示:
<p><strong>How can I come see the animals perform?</strong><br>
Schedules and information about attending a performance can be found here:</p>
<p><a href="http://jupmingdolphins.com">Performance tickets</a></p>
<p>If no performances are listed, it means that none are scheduled in the
near future. The animals take a break between November and May.</p>
<p><strong>What's the answer to this question?</strong><br>
It's 42, of course.</p>
<h2>Header for More Questions</h2>
<p><strong>Is it true the dolphins have smartphones?</strong><br>
Yes, they use Android phones and text each other constantly.</p>
<p><b>Just kidding!</b> They are all Apple fan-fish and prefer iPhones.</p>
(etc)
我试图弄清楚:
一些 CSS(可能还有 jQuery)在页面加载时隐藏除了问题之外的所有内容。
简单的 jQuery,当用户单击
<strong>
-wrapped 问题时,答案会向下滑动并出现在其下方。如您所见,问题在于标记很古怪(感谢 CMS),一个问题和另一个问题之间可能有很多东西。答案不包含在他们自己的 DIV 或任何东西中。最重要的是,FAQ 中有 H2 副标题,我不希望 H2 被触摸/折叠。
所以我需要类似于点击操作的代码:
$('strong').click(function() {
// hide or reveal all elements from $(this) down,
// and stop when we hit next <strong> or <h2>
});