Created
September 3, 2013 08:11
-
-
Save leohxj/6420979 to your computer and use it in GitHub Desktop.
鼠标按住的事件处理方式。
From http://segmentfault.com/q/1010000000267088#a-1020000000303243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var interval; | |
| $('div').mousedown(mouseState).mouseup(mouseState); | |
| function mouseState(e) { | |
| if (e.type == "mouseup") { | |
| clearInterval(interval); | |
| } | |
| if (e.type == "mousedown") { | |
| //code triggers on hold | |
| interval = setInterval(function () { | |
| $('div').prepend("<span>hold</span>") | |
| }, 100); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment