Skip to content

Instantly share code, notes, and snippets.

@swanson
Created November 20, 2012 15:39
Show Gist options
  • Save swanson/4118683 to your computer and use it in GitHub Desktop.
Save swanson/4118683 to your computer and use it in GitHub Desktop.
Autoswap Bootstrap icon-chevron when using Collapsible
<a class="btn" data-toggle="collapse" data-target="#my-container">
Toggle <i class="icon-chevron-right"></i>
</a>
<div id="#my-container">
... cool stuff goes here ...
</div>
//Assumes you have jQuery
$("[data-toggle='collapse']").click(function(e) {
var $this = $(this);
var $icon = $this.find("i[class^='icon-chevron']");
if ($icon.hasClass('icon-chevron-right')) {
$icon.removeClass('icon-chevron-right').addClass('icon-chevron-down');
} else {
$icon.removeClass('icon-chevron-down').addClass('icon-chevron-right');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment