javascript - Disable Bootstrap accordion after opening -
i have multiple bootstrap accordion running , disable once clicked. 1 tab has remain open @ times.
for example, link1 open link1 should disabled. link2 , link3 should clickable. how should achieve this?
here's code:
<div id="accordion"> <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseexample1"> link 1 </a> <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseexample2"> link 2 </a> <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseexample3"> link 3 </a> <div class="collapse in" id="collapseexample1"> description 1 </div> <div class="collapse" id="collapseexample2"> description 2 </div> <div class="collapse" id="collapseexample3"> description 3 </div> </div>
javascript:
$('#accordion').on('show.bs.collapse', function () { $('#accordion .in').collapse('hide'); });
jsfiddle link demo: https://jsfiddle.net/dtchh/19604/
just remove classes collapse in
element want disable accordion. here link1
.
$('#accordion').on('show.bs.collapse', function () { $('#accordion .in').collapse('hide'); }); $(".collapse.in").removeclass('collapse in');
i hope wanted. check fiddle.
Comments
Post a Comment