the*_*edp 11 jquery events mouseover jquery-plugins hover
我希望能够在以下场景中检测鼠标是否仍然在元素上:
我怎样才能达到#2?
谢谢.
Vil*_*kas 37
这似乎有效(http://jsbin.com/uvoqe)
$("#hello").hover( function () {
$(this).data('timeout', setTimeout( function () {
alert('You have been hovering this element for 1000ms');
}, 1000));
}, function () {
clearTimeout($(this).data('timeout'));
});
Run Code Online (Sandbox Code Playgroud)
nic*_*ckf 15
看一下jQuery 的hoverIntent插件.它为您提供了一个新的事件处理程序,只有当您将元素悬停在元素上一段时间后才会触发它.通过调整其选项,您应该能够让它完全按照您的要求进行操作.
Pet*_*dIt 10
只需使用一个标志告诉您鼠标是否在它上面.
var mouseover = false;
$('.thing').mouseenter(function(){
mouseover = true;
}).mouseleave(function(){
mouseover = false;
});
Run Code Online (Sandbox Code Playgroud)