jQuery的mouseout()和mouseleave()有什么区别? [英] What is the difference between jQuery's mouseout() and mouseleave()?

查看:517
本文介绍了jQuery的mouseout()和mouseleave()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery的mouseout()和mouseleave()有什么区别?

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

推荐答案


mouseleave事件与处理事件冒泡的方式不同于mouseout。如果在此示例中使用了mouseout,那么当鼠标指针移出Inner元素时,将触发处理程序。这通常是不受欢迎的行为。另一方面,mouseleave事件仅在鼠标离开它所绑定的元素时触发其处理程序,而不是后代。因此,在此示例中,处理程序在鼠标离开Outer元素时触发,但不在Inner元素中触发。

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.

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

这篇关于jQuery的mouseout()和mouseleave()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆