开发者

how to hide submenus in jquery menu

开发者 https://www.devze.com 2022-12-20 10:17 出处:网络
i have a menu like fllowing code Home Sub Item 1 Sub Item 1.1 Sub Item 1.1.1 Sub Item 1.1.2 Sub Item 1.2 Sub Item 1.3

i have a menu like fllowing code

  • Home
    • Sub Item 1
      • Sub Item 1.1
        • Sub Item 1.1.1
        • Sub Item 1.1.2
      • Sub Item 1.2
      • Sub Item 1.3
      • Sub Item 1.4
      • Sub Item 1.5
      • Sub Item 1.6
      • Sub Item 1.7
    • Sub Item 2开发者_如何学Python
    • Sub Item 3
  • Product Info
    • Sub Item 1
    • Sub Item 2
      • Sub Item 2.1
      • Sub Item 2.2
    • Sub Item 3
    • Sub Item 4
    • Sub Item 5
    • Sub Item 6
    • Sub Item 7
  • and a css file to arrange items as verical menu, i show submenu with in jquery like this

    $(document).ready(function(){
        var ss="#menu li:hover>div";
        $("div#menu li:parent").hover(function(){
            $(ss).show(500);
    
        });
    });
    

    now how i hide this submenu while mouse leave on items???? anyone can help me?


    You mean somethign like this:

    var ss = "#menu li:hover>div";
    $("div#menu li:parent").hover(
        function() {
            $(ss).show(); //this is the mousein
        },
        function() {
            $(ss).hide(); //this is the mouseout
        }
    );
    

    Remember that hover can take two callbacks, and the second callback will be called when the mouse leaves the element.

    http://api.jquery.com/hover/


    Use the mouseleave event

    0

    精彩评论

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

    关注公众号