I have created an accordion using jQuery which collapses fine when the user clicks a 2nd option but I would also like to have the option to collapse the open pane by clicking again on the header. How can I do this?
Here is my existing jQuery for the creation of the accordion:
$("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null, });
Here is the HTML:
<div id="accordion">
<h2>Heading 1</h2>
<div class="pane">... pane content ...</div>
<h2>Heading 2</h2>
<div class="pane">... pane content ...</div>
<h2>Heading 2</h2>
<div class="pane">... pane content ...</div>
</div>
Source: http://jqueryui.com/demos/accordion/#option-collapsible
find this demo: http://jsfiddle.net/2DaR6/