This is a simple jQuery plugin which allows you to toggle the children of a definition list.
Basic usage is :
$('#faq').dltoggle( options );
Only minimal options are supported right now:
| Option | Meaning |
| closed-image | The image to use for closed lists. |
| open-image | The image to use for open lists. |
| leave-open | If set all elements are left open, see demo 2. |
The code for this demo is in two parts:
Javascript
//
// Explicit options - which match the defaults.
//
$('#faq').dltoggle( { "open-image" : "open.gif",
"closed-image" : "closed.gif" } );
$("#open").click(function(event){
$('#faq').dltoggle_show();
return false;
});
$("#close").click(function(event){
$('#faq').dltoggle_hide();
return false;
});
HTML
<dl id="faq">
<dt>Foo : Click Me</dt>
<dd><p>As you can see the first element is visible.</p></dd>
<dt>Bar : Click Me</dt>
<dd><p>This one, and all later ones are hidden by default</p></dd>
<dt>Baz : Click Me</dt>
<dd><p>This one, and all later ones are hidden by default</p></dd>
</dl>
<p>[<a href="#" id="open">Open</a> | <a href="#" id="close">Close</a> ]</p>
There are a couple more lists on the demo page.