bootstrap close accordion javascript code example

Example 1: bootstrap accordion stop from closing

You can remove data-parent="#accordion" from each panel which enables you to 
open a panel without closing another at the same time.

reference : https://stackoverflow.com/questions/31982638/how-to-prevent-accordion-to-close-while-clicking-on-sibling-divs

Example 2: open one accordion at a time bootstrap

Notice that each panel has a data-parent which targets the parent div with the 
ID #panels.

<div class="panel-group" id="panels">
    <div class="panel panel-default">
        <div class="collapsed" data-toggle="collapse" data-parent="#panels" data-target="#firstPanel">
             <h4>First header</h4>    
        </div>
        <div id="firstPanel" class="panel-collapse collapse">
            <div>Content.</div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="collapsed" data-toggle="collapse" data-parent="#panels" data-target="#secondPanel">
             <h4>Second header</h4>

        </div>
        <div id="secondPanel" class="panel-collapse collapse">
            <div>Other content.</div>
        </div>
    </div>
</div>

Tags:

Misc Example