tags:

views:

25

answers:

2

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
    • 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?

    A: 

    Use the mouseleave event

    Vinodh Ramasubramanian
    i know i should use mouseleave event , but i dont know how use thatit hide just a submenu is opened
    ulduz114
    +1  A: 

    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/

    Bob
    thanks Bob, but when i use $(ss).show(500);it blinks unormaly
    ulduz114
    Right, then just modify it like so: $(ss).stop().show(500); $(ss).stop().hide(500);
    Bob