Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collapse all the tabs in a Accordion on jquery?

By using the Telerik Extensions for ASP.NET MVC, how can I hide all the Accordion Tabs on page loading up ? By default, it will expand the first Accordion tab on page loading up! Thanks a lot!


2 Answers

Try this:

It will disable all the active (open) pane.

$('.accordion').accordion({
    active: false,
    collapsible: true            
});
like image 192
Kien Pham Avatar answered Sep 13 '25 11:09

Kien Pham


View the jQuery, there is most likely an option to specify the tab to show; by default this is probably the first. You can override the behavior by adding additional jQuery.

If the accordion is a nested UL, the jQuery to hide all the nested UL elements would be like this:

$('ul.accordion ul').hide();

Be sure to place this after the jQuery that sets up the accordion functionality. Clicking any of the top LI should then show the nested UL.

The markup may be different, but the logic should be very similar.

like image 31
2 revs, 2 users 84%Beau Smith Avatar answered Sep 13 '25 10:09

2 revs, 2 users 84%Beau Smith