Reputation: 5023
I am building own accordion markup by using bootstrap collapse
Does anyone know how to close the open accordion when you click on any other?
I tried with
//bs2
$('#top1_accordion').on('show','.collapse', function() {
$('#top1_accordion').find('.collapse.in').collapse('hide');
});
//bs3
$('#top1_accordion').on('show.bs.collapse','.collapse', function() {
$('#top1_accordion').find('.collapse.in').collapse('hide');
});
bootstrap 3 works on first click only http://jsfiddle.net/4WsFK/1/
I got it working on bootstrap 2
Any help is appreciated!
Upvotes: 0
Views: 351
Reputation: 773
I believe the this fiddle should work. I only removed the class 'collapse' from your find statement. I'm not sure of all differences in 3.0, but they must've changed the markup slightly.
$('#top1_accordion').find('in').collapse('hide');
Upvotes: 1