jQuery:触发“mousestop”的简单方法事件
嗨,
我试图在鼠标停止移动 x 秒时调用一个函数。实际上,使用以下代码非常简单:
var timer = null;
$(document).mousemove(function(){
clearTimeout (timer);
timer = setTimeout(myfunction, 5000);
});
但是 mousemove 事件被频繁调用,因此在移动鼠标时,Firefox 中的处理器负载相当重。有没有一种简单的方法可以用更少的函数调用来做同样的事情???
谢谢! 扬
HI,
I'm trying to call a function when the mouse stopped moving for x seconds. Actually thats pretty easy with the following code:
var timer = null;
$(document).mousemove(function(){
clearTimeout (timer);
timer = setTimeout(myfunction, 5000);
});
But the mousemove event is called very often, so I get a pretty heavy processor load in Firefox while moving the mouse. Is there an easy way to do the same thing with less function calls???
Thanx!
Jan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用此选项并将延迟选项设置为 x 秒
http://www.richardscarrott .co.uk/posts/view/jquery-mousestop-event
Use this and set the delay option for x seconds
http://www.richardscarrott.co.uk/posts/view/jquery-mousestop-event
看一下jQuery hideIntent插件
用法与jQuery悬停,但该事件仅在短暂的、可配置的延迟后触发。
Take a look at the jQuery hoverIntent plugin
Usage is the same as jQuery hover, but the event only fires after a short, configurable delay.