Determine if mouse is still in javascript/jQuery?

风格不统一 提交于 2020-01-15 09:24:04

问题


I'd like to be able to use jQuery to trigger an event if the mouse has been stationary for a certain amount of time.

Any ideas? I'm not even sure where to start!


回答1:


There's the idleTimer plugin which could be used for this purpose. And here's a nice demo of the plugin in action.




回答2:


Hook up a mousemove() handler on the document and set a timeout. When timeout elapses, do your thing. Whenever the mouse moves again, cancel the timeout so it will fire relative to the last mouse movement.

This is a combination of jQuery and JavaScript.




回答3:


jquery 1.4 offers a new method delay() for that



来源:https://stackoverflow.com/questions/2487939/determine-if-mouse-is-still-in-javascript-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!