Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQUERY UI Accordion start collapsed

How can I make the jquery UI accordion start collapsed when the form loads. Is there any javascript code for this?

like image 539
H Bellamy Avatar asked Oct 30 '11 21:10

H Bellamy


People also ask

How to collapse accordion using jQuery?

To create an accordion that is collapsed by default, we need to set the 'active' property of the jQuery Accordion as false. Syntax: $("#demoAccordion"). accordion({ collapsible: true, active: false});

How do I make my accordion active?

$('#accordion'). activate('activate',117);

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.


2 Answers

In your options specify:

{   ...   active: false,   collapsible: true,   ... } 

See documentation for active.

like image 194
topek Avatar answered Sep 22 '22 16:09

topek


I was trying to do the same thing. Using Jquery UI tabs. I wanted none to show with 5 tabs when you start.

using active: false showed the 5th tabs content. So I set tabs CSS to display:none; since it in-line changes display. Hope this helps someone!

<script> $(function() {     $( "#tabs" ).tabs({         active: false,         collapsible: true,     }); }); 

And in the style

#tabs-1, #tabs-2, #tabs-3, #tabs-4, #tabs-5{      display:none; } 
like image 45
nonono nonono Avatar answered Sep 24 '22 16:09

nonono nonono