Skip to content

Instantly share code, notes, and snippets.

@aghuddleston
Forked from swanson/chevron_toggle.html
Created March 7, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aghuddleston/0a5f59504fb1373111d9 to your computer and use it in GitHub Desktop.
Save aghuddleston/0a5f59504fb1373111d9 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