twitter-bootstrap 折叠插件:一次只显示一个面板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15444758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Collapse plugin: Only show one panel at a time
提问by Gabriel Alack
I'm having a hard time figuring this out, and maybe I'm just not searching the right terms.
我很难弄清楚这一点,也许我只是没有搜索正确的术语。
I have a regular twitter collapse panel. I only want it to show one panel at a time.
我有一个常规的 Twitter 折叠面板。我只希望它一次显示一个面板。
By default, it allows you to open all of the panels at once, but I want it to automatically close any other open panel when you expand another one.
默认情况下,它允许您一次打开所有面板,但我希望它在您展开另一个面板时自动关闭任何其他打开的面板。
http://twitter.github.com/bootstrap/javascript.html#collapse
http://twitter.github.com/bootstrap/javascript.html#collapse
<div class="accordion" id="monogram-acc">
<div class="accordion-group">
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" data-parent="monogram-acc" href="#Animals">
Animals
</div>
</div>
<div class="accordion-body collapse" id="Animals">
//... content
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" data-parent="monogram-acc" href="#Food">
Food
</div>
</div>
<div class="accordion-body collapse" id="Food">
// ... content
</div>
</div>
//... so on
</div>
回答by isherwood
Change
改变
data-parent="monogram-acc"
to
到
data-parent="#monogram-acc"

