jquery - 如何防止 DIV 在 MouseOver 上跳转?

标签 jquery onmouseover slidedown slideup onmouseout

这个小片段的目标是(默认情况下)显示图像数据,然后通过鼠标悬停时的“slideDown”将其删除。它大部分工作正常,但是当您将鼠标悬停在文本上显示信息时,div 会疯狂地上下跳跃。任何解决此问题的帮助都将不胜感激!

演示: http://jsfiddle.net/voudini/SggsV/

最佳答案

尝试使用onmouseenteronmouseleave

试试这个

$('.hoverbox')
    .mouseenter(function(){
        $(".hoverinfo", this).stop(true, true).slideUp(400);
    })
    .mouseleave(function(e){

        $(".hoverinfo", this).stop(true, true).slideDown(400);
    });

Updated Fiddle

检查其文档

Mouse EnterMouse Leave

The mouseenter event differs from mouseover in the way it handles event bubbling. If mouseover were used in this example, then when the mouse pointer moved over the Inner element, the handler would be triggered. This is usually undesirable behavior. The mouseenter event, on the other hand, only triggers its handler when the mouse enters the element it is bound to, not a descendant. So in this example, the handler is triggered when the mouse enters the Outer element, but not the Inner element.

关于jquery - 如何防止 DIV 在 MouseOver 上跳转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12702172/

相关文章:

jquery - 滑动菜单时隐藏图像的问题

javascript - jQuery slideDown 和 slideUp - 如何在页面更改时保持声明

如果在 jquery .slideDown() 动画结束之前,Javascript 监听器不会触发

jquery - 如何调用 jQuery 插件的函数(创建新插件)?

javascript - JQuery 在 div 中选择多个 img 之一

javascript - 简单的 onmouseover 在 eBay 拍卖页面上不起作用?

jquery - 如何在鼠标悬停时更改文本段落(<p>)

javascript - jquery 如何知道表格滚动条是否到达末尾

jquery - 如何计算平板电脑和 iphone 的设备高度并将内容固定在其底部

javascript - 需要帮助编写干净、有组织的 JavaScript 代码