Skip to content

Instantly share code, notes, and snippets.

@joaoricardocefalialmeida
Forked from swanson/chevron_toggle.html
Last active August 29, 2015 14:22
Show Gist options
  • Save joaoricardocefalialmeida/be1519367e70b611e1f5 to your computer and use it in GitHub Desktop.
Save joaoricardocefalialmeida/be1519367e70b611e1f5 to your computer and use it in GitHub Desktop.
<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