-
-
Save aghuddleston/0a5f59504fb1373111d9 to your computer and use it in GitHub Desktop.
Autoswap Bootstrap icon-chevron when using Collapsible
This file contains 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
<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> |
This file contains 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
//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