Search code examples
jquery-ui

How do I keep jQuery UI Accordion collapsed by default?


I am working with jQuery UI Accordion and it works great, but I would like to have the accordion stay closed unless it I click on it.

I am using this code right now, which allows be to toggle it closed:

$("#accordion").accordion({ header: "h3", collapsible: true });

Is there a way to have it closed by default unless it is clicked?


Solution

  • In addition to the collapsible: true you need to add the active: false option (documentation)..

    $("#accordion").accordion({ header: "h3", collapsible: true, active: false });