Collapse plugin: Only show one panel at a time

荒凉一梦 提交于 2019-12-11 02:55:12

问题


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.

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

<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>

http://jsfiddle.net/AbtmY/


回答1:


http://jsfiddle.net/AbtmY/1/

Change

data-parent="monogram-acc"

to

data-parent="#monogram-acc"


来源:https://stackoverflow.com/questions/15444758/collapse-plugin-only-show-one-panel-at-a-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!