У меня есть серия аккордеонов, но я хочу только, чтобы один из них расширялся за раз. В настоящее время все можно открыть.Как иметь только один открытый аккордеон?
http://codepen.io/anon/pen/uaytq
$('.collapse-toggle').click(function (e) {
var that = $(this).parent();
var accordion = that.find('.collapse-content');
if (accordion.hasClass('open')) {
accordion.removeClass('open');
accordion.animate({ height: 0 }, 300);
} else {
var currentHeight = accordion.height(); //save current height
accordion.css('height', 'auto'); //temporary switch height to auto
var autoHeight = accordion.height(); //get auto height
accordion.css('height', currentHeight); //switch back to current height
accordion.animate({ height: autoHeight }, 300); //animate that beautiful thing
accordion.addClass('open'); //let the people know!
}
});
я пропускаю свой HTML Markup ... Пожалуйста, сделайте JSFiddle ... – algorhythm
@algorhythm обновлено – itsclarke