Appendix N. Accordion

Method

Description

Return Value

Showing and Hiding Methods

accordion(options)

Makes the selected elements into accordions (see "Accordion Options").

jQuery

accordion('activate', index)

Activates a content part of the accordion programmatically.

jQuery

accordion('enable')

Enables the selected accordion.

jQuery

accordion('disable')

Disables the selected accordion.

jQuery

accordion('destroy')

Destroys the selected accordion.

jQuery

Accordion Options

Option

Description

Type

active

Used to set the default content pane. If a selector is provided, it must reference the element used for a header. If the value false is provided, no element will be used as the default content pane. The default value is the first element.

Boolean, selector, element, number, jQuery

alwaysOpen

By default, there is always one content pane open, and the open content pane cannot be closed. If this open is set to false, the user is given the ability to toggle the open content pane open or closed. The default value is true.

Boolean

animated

If set to false, animation is disabled. If the jQuery UI Easing plugin is installed, you may use the values bounceslide or easeslide. The default value is slide.

Boolean, slide, bounceslide, or easeslide

autoHeight

If set to true, the highest content pane is used as a height reference for every pane. The default value is true.

Boolean

clearStyle

If set, clears height and overflow styles after finishing an animation, which enables accordions to work with dynamic content. Won't work with the ...

Get Beginning JavaScript® and CSS Development with jQuery now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.