Skip to content

Instantly share code, notes, and snippets.

@JensRantil
Created February 1, 2013 12:55
Show Gist options
  • Save JensRantil/4691153 to your computer and use it in GitHub Desktop.
Save JensRantil/4691153 to your computer and use it in GitHub Desktop.
Make it possible to style `a.accordion-toggle`-links based on whether the Bootstrap collapse/accordion item is collapsed or not. The CSS-class "active" means that a `accordion-group` is open, the lack of it means it's closed. If it wasn't for the fact that the `.collapsed` class is not added initially to a collapsed `a.accordion-toggle` element,…
jQuery.ready(function() {
$('.accordion').on('hide', function(e) {
$(e.target).parent().find('.accordion-toggle').first().removeClass('active');
}).on('show', function(e) {
$(e.target).parent().find('.accordion-toggle').first().addClass('active');
});
})
.accordion .accordion-toggle.active {
font-weight: bold;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment