I've got an FAQ page that has about 15 sections. Each question uses slideToggle to expand each answer. That's all fine. The trouble is each section needs an "expand/collapse all", which will expand all questions only within that specific section. The script I'm using works perfect, it's just that I have to create a block of the same script for each section .. example:
$('#faq-content a.all').click(function() {
if ($(this).hasClass('collapse')) {
$('#faq-content dt.opened').click();
} else $('#faq-content dt:not(.opened)').click();
$(this).toggleClass('expand collapse');
return false;
});
$('#faq-hardware a.all').click(function() {
if ($(this).hasClass('collapse')) {
$('#faq-hardware dt.opened').click();
} else $('#faq-hardware dt:not(.opened)').click();
$(this).toggleClass('expand collapse');
return false;
});
I was wondering if it's possible to have a unified way to control all sections.