Last active
November 16, 2015 21:01
-
-
Save omurphy27/169ddbb939a03e2977a7 to your computer and use it in GitHub Desktop.
jQuery - add active class to bootstrap accordion panel heading.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery - add active class to Bootstrap Accordion Heading | |
if ($('#accordion').length) { | |
var $panels = $('.panel'); | |
// add active class to first open panel | |
// only necessary if this panel is open by default on your accordion | |
$panels.first().addClass('active'); | |
$('.panel-heading').on('click', function (e) { | |
$this = $(this); | |
$panel = $this.parents('.panel'); | |
$panels.not( $panel ).removeClass('active'); | |
$panel.toggleClass('active'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment