Created
February 2, 2017 09:35
-
-
Save pagemashine/e60fc544e229e7d82db87929a1181503 to your computer and use it in GitHub Desktop.
Accordion
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
(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