JQUERY UI Accordion start collapsed

2019-01-23 00:44发布

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

7条回答
forever°为你锁心
2楼-- · 2019-01-23 00:48

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.

查看更多
仙女界的扛把子
3楼-- · 2019-01-23 00:53

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;
}
查看更多
Juvenile、少年°
4楼-- · 2019-01-23 00:55

In your options specify:

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

See documentation for active.

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-23 00:58

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

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

See the documentation

查看更多
唯我独甜
6楼-- · 2019-01-23 01:03

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

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

    });
查看更多
别忘想泡老子
7楼-- · 2019-01-23 01:09

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.

查看更多
登录 后发表回答