带有 2 个切换按钮和 2 个全局按钮的示例 [全部显示] 和 [全部隐藏]
Chrome 工作正常 FF >= 15 有问题:点击 2 x on [hide all] - 游戏结束 - 不再崩溃!
访问:http: //jsfiddle.net/feldversuch/fB5PJ/8/
<div id="content" class="span8">
<button type="button" class="btn" data-toggle="collapse" data-target="#demo1">
toggle #demo1</button>
<button type="button" class="btn" data-toggle="collapse" data-target="#demo2">
toggle #demo2</button>
<button type="button" class="btn btn-danger" onclick="$('.collapse').collapse('show');return false;">
show all</button>
<button type="button" class="btn btn-danger" onclick="$('.collapse').collapse('hide');return false;">
hide all</button>
<br /><br />
<div id="collapser">
<div id="demo1" class="btn collapse in"> <span class="badge">#demo1</span>
Collapsible Content, Collapsible Content, Collapsible Content, Collapsible Content, Collapsible Content, Collapsible Content, initially shown </div>
<br /><br />
<div id="demo2" class="btn collapse in"> <span class="badge">#demo2</span>
Collapsible Content, Collapsible Content, Collapsible Content, Collapsible Content, Collapsible Content, Collapsible Content, initially shown </div>
</div>
</div>
merv 的解决方案:仅显示 $('.collapse').not('.in')
<button type="button" class="btn btn-danger" onclick="$('.collapse').not('.in').collapse('show');return false;">
Show All</button>
我的解决方案:仅隐藏 $('.collapse.in')
<button type="button" class="btn btn-danger" onclick="$('.collapse.in').collapse('hide');return false;">
hide all</button>