JQUERY UI 手风琴开始折叠

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7947789/
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-27 00:30:08  来源:igfitidea点击:

JQUERY UI Accordion start collapsed

jqueryaccordionjquery-ui-accordion

提问by H Bellamy

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

如何在表单加载时使 jquery UI 手风琴开始折叠。有没有这方面的 javascript 代码?

回答by topek

In your options specify:

在您的选项中指定:

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

See documentation for active.

请参阅文档以了解active

回答by nonono nonono

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

我试图做同样的事情。使用 Jquery UI 选项卡。我不想在你开始时显示 5 个标签。

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!

使用 active: false 显示第 5 个标签内容。所以我将标签 CSS 设置为 display:none; 因为它在线更改显示。希望这可以帮助某人!

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

And in the style

而且在风格上

#tabs-1, #tabs-2, #tabs-3, #tabs-4, #tabs-5{ 
    display:none;
}

回答by Lyndon John Haslam

I used this code, as i was using a Dreamweaver Widget, the code that Topek didnt work for me hope this helps,

我使用了这段代码,因为我使用的是 Dreamweaver Widget,Topek 对我不起作用的代码希望这会有所帮助,

jQuery("#jQueryUIAccordion").accordion({ 
        event: "click",
        active: false,
        collapsible: true,
        autoHeight: false

    });

回答by shagshag

To complete the answer of topex, With Jquery UI 1.10.3 I had to set the 'collapsible' option before the 'active' one.

要完成topex答案,使用 Jquery UI 1.10.3 我必须在 'active' 选项之前设置 'collapsible' 选项。

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

See the documentation

查看文档

回答by Steve

If you're using the wysiwyg "Properties" and the coding confuses, try putting a number in the "Active" box one more than your list of Sections. I have 12 sections and put "13" in there and it worked for me.

如果您使用所见即所得的“属性”并且编码混乱,请尝试在“活动”框中输入一个比您的部分列表多一个的数字。我有 12 个部分并将“13”放在那里,它对我有用。

回答by Ashish v

If you are using default jquery accordion it always display first panel content, you can disable it by using active: falseattribute.

如果您使用默认的 jquery 手风琴,它总是显示第一个面板内容,您可以使用active: false属性禁用它。

jQuery(document).ready(function() {
    jQuery( "#accordion" ).accordion({
      collapsible: true,
      active: false,
    });
});

but it's default behavior is for all panels will be set to the height of the tallest panel. so, for that you have to add "heightStyle"attribute.

但它的默认行为是所有面板都将设置为最高面板的高度。所以,为此你必须添加"heightStyle"属性。

heightStyle: "content",

so, each panel will be only as tall as its content.

因此,每个面板的高度仅与其内容一样高。

回答by user6236374

If you look at the beginning of the panel group in your code, look for this

如果您查看代码中面板组的开头,请查找此

<div id="collapseOne1" class="panel-collapse collapse in"> 

if you just remove the "in" it has the panel close when the page loads.

如果您只是删除“in”,它会在页面加载时关闭面板。