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

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

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

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 05:53

    jQuery API doc:

    mouseout

    This event type can cause many headaches due to event bubbling. For instance, when the mouse pointer moves out of the Inner element in this example, a mouseout event will be sent to that, then trickle up to Outer. This can trigger the bound mouseout handler at inopportune times. See the discussion for .mouseleave() for a useful alternative.

    So mouseleave is a custom event, which was designed because of the above reason.

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

提交回复
热议问题