Created
April 8, 2020 15:34
-
-
Save WrackedFella/28559870e8cd625309da4968cd407044 to your computer and use it in GitHub Desktop.
Small bit of JS that will make Bootstrap cards in your project collapsible if they have a `.card-header` element to use as a handle.
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
$('.card-header').append('<span class="fas fa-minus float-right position-absolute" style="top: 1em; right: 1em;"></span>'); | |
$('.card-header').on('click', function (e) { | |
var card = $(this).closest('.card'); | |
$(card.find('.card-body')[0]).toggle('slide'); | |
swapCssClasses($(card.find('.position-absolute')), 'fa-plus', 'fa-minus'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment