Skip to content

Instantly share code, notes, and snippets.

@WrackedFella
Created April 8, 2020 15:34
Show Gist options
  • Save WrackedFella/28559870e8cd625309da4968cd407044 to your computer and use it in GitHub Desktop.
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.
$('.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