jquery 问题,禁用 mouseenter 队列

发布于 2024-08-21 18:21:17 字数 654 浏览 20 评论 0原文

当您 mouseenter .li_group 类时,它会对 1 个

  • 标记执行向下滑动效果,一切都会顺利进行,但在延迟期间,如果您将鼠标移开并放在 .li_group 上,它会“排队”效果并将 li 向下滑动、延迟、再次向下滑动等等...我已经尝试了我能想到的所有方法,甚至 stop();但它仍然这样做...
  • 我使用 mouseenter 而不是悬停的原因是因为它更适合 ul / li 列表

    $(".li_group").live('mouseenter',function(){
            var id = "#ec1";  
            $(id).slideDown();                               
        }).live('mouseleave',function(){
         if (jQuery.support.cssFloat==true || getInternetExplorerVersion() > 7)  {      //ie < 8 endless up/down on close
            var id = "#ec1";  
             $(id).delay(5000).slideUp('fast'); 
           }
        });
    

    When you mouseenter .li_group class it does a slide down effect on 1 single <li> tag, everything goes smoothly, but during the delay if you take your mouse off and on .li_group it "queues" the effect and slides the li down, delay, slides it down again etc etc... I have tried every way i can think of, even stop(); but it still does it...

    the reason i use mouseenter instead of hover, is because it works better for ul / li list

    $(".li_group").live('mouseenter',function(){
            var id = "#ec1";  
            $(id).slideDown();                               
        }).live('mouseleave',function(){
         if (jQuery.support.cssFloat==true || getInternetExplorerVersion() > 7)  {      //ie < 8 endless up/down on close
            var id = "#ec1";  
             $(id).delay(5000).slideUp('fast'); 
           }
        });
    

    如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

    扫码二维码加入Web技术交流群

    发布评论

    需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

    评论(1

    苏璃陌 2024-08-28 18:21:17

    当您使用 .stop() 时,您是否也清除了队列并且跳到结束?例如,

    $(".li_group")
        .live('mouseenter',function(){
            var id = "#ec1";  
            $(id).stop(true, true).slideDown();                               
        })
        .live('mouseleave',function(){
           //ie < 8 endless up/down on close
           if (jQuery.support.cssFloat==true || getInternetExplorerVersion() > 7)  {      
               var id = "#ec1";  
               $(id).stop(true, true).slideUp('fast'); 
           }
        });
    

    我从那里取出了 delay(5000) 调用,因为我认为这是为了防止您遇到的问题而放置的。我还建议在选择器中使用标签名称,以帮助那些没有 document.getElementsByClassName() 的浏览器

    When you used .stop() did you also clear the queue and jump to end? For example,

    $(".li_group")
        .live('mouseenter',function(){
            var id = "#ec1";  
            $(id).stop(true, true).slideDown();                               
        })
        .live('mouseleave',function(){
           //ie < 8 endless up/down on close
           if (jQuery.support.cssFloat==true || getInternetExplorerVersion() > 7)  {      
               var id = "#ec1";  
               $(id).stop(true, true).slideUp('fast'); 
           }
        });
    

    I've taken the delay(5000) call out of there, as I take it that this was put in to prevent the problem you were getting. I'd also recommend using the tag name(s) in your selector too, to help those browsers that don't have document.getElementsByClassName()

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文