Skip to content

Instantly share code, notes, and snippets.

@pagemashine
Created February 2, 2017 09:35
Show Gist options
  • Save pagemashine/e60fc544e229e7d82db87929a1181503 to your computer and use it in GitHub Desktop.
Save pagemashine/e60fc544e229e7d82db87929a1181503 to your computer and use it in GitHub Desktop.
Accordion
(function($) {
$('.js-accordion > .accordion__item:eq(0) .accordion__link').addClass('active').next().slideDown();
$('.js-accordion .accordion__link').click(function(j) {
var dropDown = $(this).closest('.accordion__item').find('.accordion__content');
$(this).closest('.js-accordion').find('.accordion__content').not(dropDown).slideUp();
if ($(this).hasClass('active')) {
$(this).removeClass('active');
} else {
$(this).closest('.js-accordion').find('.accordion__link.active').removeClass('active');
$(this).addClass('active');
}
dropDown.stop(false, true).slideToggle();
j.preventDefault();
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment