Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep jQuery UI Accordion collapsed by default?

Tags:

jquery-ui

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?

like image 635
forrest Avatar asked Jan 08 '11 12:01

forrest


People also ask

How do I make my first accordion open by default?

If you are using bootstrap accordion and want that one of the accordion should be opened for the first time so add class="in" .

How do I make accordion open by default in bootstrap?

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" .

How can we make accordion dynamically using jQuery?

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.


1 Answers

Add the active: false option (documentation)..

$("#accordion").accordion({ header: "h3", collapsible: true, active: false });
like image 76
Gabriele Petrioli Avatar answered Sep 30 '22 19:09

Gabriele Petrioli