我知道mouseenter
和mouseleave
的用法。下面是我的代码示例:
$('div').mouseenter(function(e){
...
}).mouseleave( function(e){
...
//let say it will take 5 second.
});
但是我的问题是,如果我快速移动鼠标,是否有可能同时触发两个处理程序?我的意思是 mouseleave
没有完成,同时 mouseenter
被触发,因为鼠标刚刚移入。
已更新
在我的例子中,我的意思是如果鼠标在触发mouseleave
后3秒内移动,是否也会触发mouseenter
?如果是,是否意味着同一个 DOM 元素同时触发 mouseenter
并离开?谢谢。
最佳答案
不可能同时触发这两个事件。因为javascript不是多线程的。如果您想在执行之间设置一些延迟,可以使用 setTimeout
关于javascript - Mouseenter和MouseLeave同时触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15675837/