Simple accordion menu (jQuery)
- by Nimbuz
// ACCORDION
$('.accordion .answer').hide(); // hide all
$('.accordion .question').click(function(){
$('.accordion .answer').slideUp(); // hide all open
$(this).addClass('active').next().slideDown(); // show the anwser
return false;
});
HTML:
<dl class="accordion">
<dt class="question">question</dt>
<dd class="answer">answer</dd>
<dt class="question">question</dt>
<dd class="answer">answer</dd>
</dl>
... works, but
the 'active' class is removed from inactive question elements and
atleast one of the answer remains open, all answers should be able to close.
Thanks!