简体   繁体   English

jQuery下拉菜单鼠标离开问题

[英]jQuery dropdown menu mouseleave problem

http://jsfiddle.net/borayeris/sb9Ju/4/ http://jsfiddle.net/borayeris/sb9Ju/4/

Here is my script.这是我的脚本。 How can I stop fading out if mouse is back on menu?如果鼠标回到菜单上,如何停止淡出?

Try adding a call to stop() on the fadeIn:尝试在 fadeIn 上添加对stop()的调用:

$(function(){
    var piFade;
    $('#menu > li').hover(
      function(){
        $('#menu > li:hover > div').stop(true,true).fadeIn('slow');
      },
      function(){
        $('#menu > li > div').fadeOut('slow');
      }
    );
});

http://jsfiddle.net/sb9Ju/13/ http://jsfiddle.net/sb9Ju/13/

And here is a version with the delay included.这是一个包含延迟的版本。 I'm not a huge fan but it's not too bad with the call to stop in there.我不是一个超级粉丝,但打电话停在那里并不算太糟糕。

http://jsfiddle.net/sb9Ju/15/ http://jsfiddle.net/sb9Ju/15/

You set too long a delay.你设置的延迟太长了。 It still runs the original hover function.它仍然运行原始的 hover function。 You remove it, it waits 2.5 second, then you back on it and it still removes menu from the first time you've hovered.你删除它,它会等待 2.5 秒,然后你回到它上面,它仍然会从你第一次悬停时删除菜单。 I really don't see a reason to use delay there.我真的没有理由在那里使用延迟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM