在 jquery 上折叠手风琴中的所有选项卡?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1592494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:47:55  来源:igfitidea点击:

Collapse all the tabs in a Accordion on jquery?

jqueryaccordion

提问by Kien Pham

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!

通过使用 ASP.NET MVC 的 Telerik 扩展,我如何隐藏页面加载时的所有手风琴选项卡?默认情况下,它会在页面加载时展开第一个手风琴选项卡!非常感谢!

回答by Kien Pham

Try this:

尝试这个:

It will disable all the active (open) pane.

它将禁用所有活动(打开)窗格。

$('.accordion').accordion({
    active: false,
    collapsible: true            
});

回答by Beau Smith

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.

查看jQuery,很可能有一个选项来指定要显示的选项卡;默认情况下,这可能是第一个。您可以通过添加额外的 jQuery 来覆盖该行为。

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

如果手风琴是嵌套的 UL,则隐藏所有嵌套 UL 元素的 jQuery 将如下所示:

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

$('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.

确保将它放在设置手风琴功能的 jQuery 之后。单击任何顶部 LI 应显示嵌套的 UL。

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

标记可能不同,但逻辑应该非常相似。