本文介绍了Bootstrap:Accordion不会自动折叠先前打开的面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个bootstrap手风琴。下面的标记工作正常,但它不会自动折叠以前打开的元素。例如,打开panel1,然后单击panel2 .. panel1应该自动关闭,但它不会。我已经尝试从引导站点(http://twitter.github.com/bootstrap/javascript.html#collapse)完全复制标记,但它无法正常工作。我错过了什么?
I need to create a bootstrap accordion. The markup below works fine, but it does not auto-collapse the previously opened element. For example, open panel1, then click on panel2.. panel1 should then auto-close, but it does not. I have tried copying the markup exactly from the bootstrap site (http://twitter.github.com/bootstrap/javascript.html#collapse), but it is not working. What am I missing?
<h3>ACCORDION DEMO</h3>
<div class="accordion" id="accordion1">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-parent="accordion1" data-toggle="collapse" href="#panel1">Panel 1</a>
</div>
<div class="accordion-body collapse" id="panel1">
<div class="accordion-inner">
<p>This is accordion panel 1 content</p>
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-parent="accordion1" data-toggle="collapse" href="#panel2">Panel 2</a>
</div>
<div class="accordion-body collapse" id="panel2">
<div class="accordion-inner">
<p>This is accordion panel 2 content</p>
</div>
</div>
</div>
</div>
推荐答案
只需替换 data-parent =accordion1
与 data-parent =#accordion1
这篇关于Bootstrap:Accordion不会自动折叠先前打开的面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!