jquery menu hovering

前端 未结 5 1869
猫巷女王i
猫巷女王i 2021-01-13 03:24

i have a menu that when i mouse over a div it will show and on mouse out it will fade out. the problem is that if you roll over any of the menu\'s children the menu will dis

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 04:11

    this is my fix

    window.menushowing = false;
    
    $('#menu').hover(
    
    function() {
        window.menushowing = true;
    }, function() {
        window.menushowing = false;
        hideMenu();
    });
    
    function hideMenu() {
        if (window.menushowing) return;
        $('#menu').animate({
            opacity: 0
        }, 1500, function() {
            $('#menu').hide();
        });
    }
    
    $('#examplePic').hover(
    
    function() {
        window.menushowing = true;
        $('#menu').css('display', 'block');
        $('#menu').animate({
            opacity: 1
        }, 1500);
    
    }, function() {
        hideMenu();
    });
    

提交回复
热议问题