What is the difference between jQuery's mouseout() and mouseleave()?

前端 未结 4 1068
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 05:11

What is the difference between jQuery\'s mouseout() and mouseleave()?

4条回答
  •  孤城傲影
    2020-11-28 06:06

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

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

提交回复
热议问题