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?
If you are using bootstrap accordion and want that one of the accordion should be opened for the first time so add class="in" .
If you'd like it to default open, add the additional class show . To add accordion-like group management to a collapsible area, add the data attribute data-parent="#selector" .
Your append string needs to be terminated with single quotes since you are using double quotes with it. Also you need to include Jquery library. If you are using the jquery accordion you also need to include the Jquery UI library. Also your html is a bit off, here is a working example.
Add the active: false
option (documentation)..
$("#accordion").accordion({ header: "h3", collapsible: true, 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