I can't seem to use jQuery Accordions with definition lists that have multiple desciption items (dd). The author's examples have only single dd items.
In the example below B2, B3 & C2 show onLoad, rather than hide like A1, B1 & C1 as I would prefer.
How would I achieve this?
jQuery('dl').accordion({
event: 'click',
active: false,
animated: "bounceslide",
header: "dt"
});
<dl>
<dt>A</dt>
<dd>A1</dd>
<dt>B</dt>
<dd>B1</dd>
<dd>B2</dd>
<dd>B3</dd>
<dt>C</dt>
<dd>C1</dd>
<dd>C2</dd>
</dl>
$(function () {
$('dt').on('click', function (e) {
e.preventDefault();
$(this).parent('dl').children('dd:visible').slideUp('slow');
$(this).nextUntil('dt').filter(':not(:visible)').slideDown('slow');
});
});
NOTE:
If you want multiple sections
open at once, don't use an accordion
- An accordion doesn't allow more than one content panel to be open at the same time, and it takes a lot of effort to do that. If you are looking for a widget that allows more than one content panel to be open, don't use this. Usually it can be written with a few lines of jQuery instead, something like this: REFERENCE: http://jqueryui.com/demos/accordion/
hope this help! ;)