HTML
<h2 class="sec-title">one</h2>
<div class="sec-content">content 1</div>
<h2 class="sec-title">two</h2>
<div class="sec-content">content 2</div>
jQuery:
$('.sec-content').hide();
$('.sec-title:first').addClass('active').next().show();
$('.sec-title').click(function(){
if( $(this).next().is(':hidden') ) {
$('.sec-title').removeClass('active').next().slideUp();
$(this).toggleClass('active').next().slideDown();
}
return false;
});
... works but what if want to make the second accordion section active on pageload? what do I change?
Thanks for your help