By default, there are headers of contents to control expand/collapse.But in my situation,I could expand/collapse the contents by another elements ,too. For example:
the basic structure of jquery ui accodion code:
<script>
$(function() {
$( "#accordion" ).accordion();
});
</script>
<div class="demo">
<div id="accordion">
<h3><a href="#">Section 1</a></h3>
<div>
<p>
Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
</p>
</div>
......
</div>
and now. I have another elements,just like :
<ul id="another elements can expand/collapse too">
<li><a href=""> expand/collapse contents of section1 of id=accordion too</a></li>
........
</ul>
thank you very much!!
If you want to expand a specified item of Accordion, you need to set the isExpand parameter to true and specify the index of the corresponding accordion pane in index parameter. The index of the HTML 5 Accordion items is starting from 0.
Second Method. The accordion ("action", params) method is used to perform an action on accordion elements, such as selecting/de-selecting the accordion menu. The action is specified as a string in the first argument (e.g., "disable" disables all menus).
jQuery - Widget accordion The Widget accordion function can be used with widgets in JqueryUI. Accordion is same like as Tabs,When user click headers to expand content that is broken into logical sections.
In web design, an accordion is a type of menu that displays a list of headers stacked on top of one another. When clicked on (or triggered by a keyboard interaction or screen reader), these headers will either reveal or hide associated content.
Collapse accordion tab:
$('.accordion').accordion('activate', false );
Expand first accordion tab:
$('.accordion').each(function (idx, item) {
if ($(item).accordion("option", "active") === false) {
$(item).accordion('activate', 0);
}
});
After update of JQuery UI there is no "active" method on accordion. So, to collapse all accordions use:
$('.accordion').accordion('option', {active: false});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With