35
rated 0 times
[
40]
[
5]
/ answers: 1 / hits: 45044
/ 9 Years ago, tue, march 17, 2015, 12:00:00
Trying to get the accordion open and collapse only when it's being clicked. I am able to open/collapse it but it is getting closed also when another accordion is clicked.
It should open or close on its own - independently from other accordions.
This is what I have tried.
JS:
$(document).on(click, .accordion-toggle, function () {
if ($(this).attr('class').indexOf('open') == -1)
$(this).toggleClass(open).next().slideToggle('fast');
//Hide the other panels
$(.accordion-toggle).not($(this)).removeClass(open);
$(.accordion-content).not($(this).next()).slideUp('fast');
});
Fiddle:
Demo
More From » html