我对.mouseleave()
有疑问。
我想在用户用鼠标离开文档时显示弹出窗口,但mouseleave
事件也会在输入文档时继续触发。
此仅在Chrome中发生,在Mozzila中一切正常。
所以这就是代码:
$(document).mouseleave(function (e) {
alert('The mouse has left the building!');
});
还有一件事:当我滚动时,事件也会触发。我能理解那一个,因为基本上我要离开文件了,但我可以阻止它吗?
答案 0 :(得分:1)
以下是一种使用jQuery.hover()
(demo)
$(document).hover(function () {
$('body').css({'background-color': 'red'});
}, function () {
$('body').css({'background-color': 'green'});
});