Last active
May 16, 2018 14:49
-
-
Save SashaKolbasov/acad01d2808aa8f7bb79426c86e352a4 to your computer and use it in GitHub Desktop.
Easy 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
// js-acc | |
var accItems = $('.js-acc > .item'); | |
var accTitles = $('.js-acc > .item > .title'); | |
accItems.removeClass('open').find('.desc').slideUp(); | |
accItems.eq(0).addClass('open').find('.desc').slideDown(); | |
accTitles.on('click', function() { | |
var parent = $(this).parent('.item'); | |
if (parent.hasClass('open')) { | |
parent.removeClass('open').find('.desc').slideUp(); | |
} else { | |
accItems.removeClass('open').find('.desc').slideUp(); | |
parent.addClass('open').find('.desc').slideDown(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment