开发者

closing other sub-menus

i have menu like this

<ul>
    <li>
        <a href="#">Home</a>
        <ul class="sub">
            <li>Text</li>
            <li>Test</li>
        </ul>
    </li>
    <li>
        <a href="#">About</a>
        <ul class="sub">
            <li>Text</li>
            <li>Test</li>
        </ul>
    </li>
    <li>
        <a href="#">Contact</a>
        <ul class="sub">
            <li>Text</li>
            <li>Test</li>
        </ul>
    </li>   
</ul>

I am using hoverIntent plugin that cause the sub-menu to remain opened for 3 seconds. But i want to close the other opened sub-menu on hovering a main menu. How to close other sub-menus?

here is js code

$('ul > li').hoverIntent({
        over: function(){
   开发者_运维问答         $(this).children('ul').slideDown('slow');
        },
        timeout: 3000,
        out: function(){
            $(this).children('ul').slideUp();
        }
    });


Try this:

$('ul > li').hoverIntent({
    over: function(){

        // slide up all submenus before opening this menu
        $("ul.sub").slideUp();
        $(this).children('ul').slideDown('slow');
    },
    timeout: 3000,
    out: function(){
        $(this).children('ul').slideUp();
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜