jQuery显示下一组元素

时间:2014-03-11 13:44:28

标签: javascript jquery

我在点击H2后尝试切换以下链接的可见性但我不断碰到砖墙。

这是html和jquery

<div class="entry-content cibi">

<h2><strong>Corporate Infrastructure Service Plan</strong></h2>
<p><a href="http://intranet/cibi/files/2014/03/Service-Plan-including-Service-specific-risks-and-all-action-plans-.docx">Service Plan (including Service specific risks and all action plans)</a></p>
<p><a href="http://intranet/cibi/files/2014/03/Scorecard.pdf">Scorecard</a></p>
<p><a href="http://intranet/cibi/files/2014/03/Corporate-Infrastructure-Service-Plan.xls">Corporate Infrastructure Service Plan</a></p>

<h2><strong>Employee Statistics</strong></h2>
<p><a href="http://intranet/cibi/files/2014/03/Absence-Management-Statistics-.xls">Absence Management Statistics</a></p>

</div>

$(document).ready(function(){

$( "h2" ).click(function() {    
    $(this).nextuntil("h2").toggle()
    return false;
});

 });

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:0)

nextUntil()而非nextuntil()

$( "h2" ).click(function() {    
$(this).nextUntil("h2").toggle()
return false;
});

Demo

答案 1 :(得分:0)

FIDDLE

$(document).ready(function(){
$( "h2" ).click(function() {    
$(this).nextUntill('h2').toggle()
return false;
});
});