Friday, 23 August 2013

Accordion active don't work on first load

Accordion active don't work on first load

when it loads first time i am trying to active first div but it makes all
div active except of first. here it is on jsfiddle.
$(".accordion > span").click(function(){
$('.accordion > span').removeClass('active');
$(this).addClass('active');
if(false == $(this).next().is(':visible')) {
$('.accordion > div').slideUp(300);
}
$(this).next().slideToggle(300);
});
var animationIsOff = $.fx.off;
$.fx.off = true;
$('.accordion > span:eq(0)').click()
$.fx.off = animationIsOff;
here is HTML
<div class="accordion">
<span>Accor 1</span>
<div>
Content here
</div>
</div>
<div class="accordion">
<span>Accor 2</span>
<div>
Content here
</div>
</div>
<div class="accordion">
<span>Accor 2</span>
<div>
Content here
</div>
</div>
any help will be highly appreciated.

No comments:

Post a Comment