jQuery Accordion - open specific section on pageload

后端 未结 7 894
别那么骄傲
别那么骄傲 2020-12-28 19:57

I have a rather basic implementation of a jQuery Accordion on a page (using 1.3.2, jQuery UI Core 1.72 and jQuery UI Accordion 1.7.2), and I wish to open the 2nd section whe

7条回答
  •  太阳男子
    2020-12-28 20:24

    proper way to open a specific tab:

    $("#accordion").accordion({
        collapsible  : true,
        active       : false,
        heightStyle  : "content",
        navigation   : true
    }); 
    

    Set the option:

    //$("#accordion").accordion('option', 'active' , "INSERT YOUR TAB INDEX HERE");
    $("#accordion").accordion('option', 'active' , 1);
    

    or you could work with a hash like this:

    if(location.hash){
    
        var tabIndex = parseInt(window.location.hash.substring(1));     
        $("#accordion").accordion('option', 'active' , tabIndex);
    
    }
    

    Vote if you use ;)

    Thanks

提交回复
热议问题