【问题标题】:Why does .mouseOut() fire when hovering over text inside the mouseOut target?为什么 .mouseOut() 将鼠标悬停在 mouseOut 目标内的文本上时会触发?
【发布时间】:2011-08-30 19:54:12
【问题描述】:

例如,如果我执行$('div#something').mouseout(function(){});,则当我将鼠标悬停在#something div 内的文本上而不是离开 div 时,该函数将触发。

我希望它仅在我离开 div 时触发,而不是在我将鼠标悬停在 div 内的文本上时触发。

为什么会这样?

【问题讨论】:

    标签: jquery hover jquery-events mouseout


    【解决方案1】:

    只要鼠标光标离开一个元素,mouseout 就会触发,即使“离开”意味着它正在进入一个子元素(文本应该是 - 至少在某些浏览器上)。

    您可能想改用“mouseleave”。

    http://api.jquery.com/mouseleave/

    【讨论】:

      【解决方案2】:

      mouseOut 在鼠标离开一个元素时触发 - 包括当它移动到其子元素上时。看到这个 jsFiddle:http://jsfiddle.net/minitech/kZcCr/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-11-02
        • 1970-01-01
        • 1970-01-01
        • 2011-07-09
        • 1970-01-01
        • 2013-08-18
        • 1970-01-01
        相关资源
        最近更新 更多