我在一个页面上有很多嵌套的引导程序可折叠元素。例如http://jsfiddle.net/JPgLT/7/
如何设置链接以仅在父元素内切换all元素?
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
<a href="#collapse-764" data-parent="#collapsible-" class="accordion-toggle" data-toggle="collapse">Headline 1</a>
</h2>
</div>
<div id="collapse-764" class="panel-collapse collapse">
<div class="panel-body">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="csc-firstHeader panel-title">
<a href="#collapse-765" data-parent="#collapsible-764" class="accordion-toggle" data-toggle="collapse">Headline 1.1</a>
</h2>
</div>
<div id="collapse-765" class="panel-collapse collapse">
<div class="panel-body">
<p>Text 1.1</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">
<a href="#collapse-766" data-parent="#collapsible-764" class="accordion-toggle" data-toggle="collapse">Headline 1.2</a>
</h2>
</div>
<div id="collapse-766" class="panel-collapse collapse">
<div class="panel-body">
<p>Text 1.2</p>
</div>
</div>
</div>
</div>
</div>
</div>
2条答案
按热度按时间hmmo2u0o1#
您可以向按钮添加一个特殊的类
closeall
,然后使用jQuery切换折叠状态。引导程序3演示:https://codeply.com/p/g0vquJl0Xn
相关问题
bootstrap 3 collapse('hide') opens all collapsibles?
bgtovc5b2#
我想我对您的问题的理解有点不同,我知道您已经期待答案,但我想我还是要回答,因为我对jQuery还很陌生,希望得到反馈