简体   繁体   English

jQuery手风琴默认展开

[英]jquery accordion default expanded

Working on a project and I am using jQuery's accordion lib. 在一个项目上工作,我正在使用jQuery的手风琴库。 I want all items in the submenu to be expanded by default. 我希望默认情况下扩展子菜单中的所有项目。 Here is the code: 这是代码:

<script type="text/javascript">
$jsmart(document).ready(function($) {
    $('#yt_sidenav li.level0 > a').addClass ('subhead');
    $('#yt_sidenav li.level0 > a').after ('<a href="#" title="" class="toggle">&nbsp;</a>');    //header 

    ////////////////////
    //$('#yt_sidenav li ul li').has('ul').append( '<span class="more-item-nav">open</span>' );

        var speed=200;
        $('#yt_sidenav li ul li').has('ul').append( '<span class="touch-item">open</span>' );

        $('.touch-item').click(function(){
            $(this).prev().slideToggle(speed);
            $(this).toggleClass('change');
            $(this).prev().prev().toggleClass('parentNote');
        });
    // second simple accordion with special markup
    $jsmart('#yt_sidenav').accordion({
        active: '.active',
        header: '.toggle',      // same header above
        navigation: true,
        event: 'click',
        fillSpace: false,
        autoheight: false,
        alwaysOpen: false, 
        animated: 'easeslide',
        collapsible: false
    }); 

    //check if headerId is set, if so activate that id
    if ($jsmart("#yt_sidenav .level2 .current").parents('.parent').length) {
        var header_element = $jsmart("#yt_sidenav .level2 .current").parents('.parent').children('a.toggle')
        $jsmart('#yt_sidenav').accordion('activate', header_element);
    }           

});
</script>

I have looked at the documentation, and have come to the conclusin .index() should be used to expand all by default. 我看了看文档,并得出结论。默认情况下,应使用.index()扩展所有内容。 But I am lost to where I need to add this code. 但是我迷失在需要添加此代码的地方。

Could you please have a look? 你能看看吗?

Thanks in advance. 提前致谢。

From the jquery collapsible documentation ... By default, accordions always keep one section open. jquery可折叠文档中 ...默认情况下,手风琴始终保持打开状态。 To allow for all sections to be be collapsible, set the collapsible option to true 要允许所有部分都可折叠,请将可折叠选项设置为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM