在页面加载时打开手风琴菜单需要一些帮助。

时间:2013-04-07 22:48:50

标签: jquery menu accordion

下面的代码很好地接受当我选择一个链接时,手风琴会在页面加载时关闭。我希望手风琴能够保持开放状态。请看下面。任何帮助将不胜感激。

http://www.kipjonesart.com/

$(document).ready(function() {

    //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
    $('.accordionButton').click(function() {

        //REMOVE THE ON CLASS FROM ALL BUTTONS
        $('.accordionButton').removeClass('on');

        //NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
        $('.accordionContent').slideUp('normal');

        //IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
        if($(this).next().is(':hidden') == true) {

            //ADD THE ON CLASS TO THE BUTTON
            $(this).addClass('on');

            //OPEN THE SLIDE
            $(this).next().slideDown('normal');
         } 

     });


    /*** REMOVE IF MOUSEOVER IS NOT REQUIRED ***/

    //ADDS THE .OVER CLASS FROM THE STYLESHEET ON MOUSEOVER 
    $('.accordionButton').mouseover(function() {
        $(this).addClass('over');

    //ON MOUSEOUT REMOVE THE OVER CLASS
    }).mouseout(function() {
        $(this).removeClass('over');                                        
    });

    /*** END REMOVE IF MOUSEOVER IS NOT REQUIRED ***/


    /********************************************************************************************************************
    CLOSES ALL S ON PAGE LOAD
    ********************************************************************************************************************/   
    $('.accordionContent').hide('');

});
</script>
</head>

1 个答案:

答案 0 :(得分:1)

由于这些页面是新的,你需要一种机制来告诉手风琴从页面加载时开启。

类似的东西:

<body id="YourPageId">

准备好文件:

$('.myAccordionSelector').accordion( "option", "active", YourPageId );