Skip to content

Instantly share code, notes, and snippets.

@leohxj
Created September 3, 2013 08:11
Show Gist options
  • Select an option

  • Save leohxj/6420979 to your computer and use it in GitHub Desktop.

Select an option

Save leohxj/6420979 to your computer and use it in GitHub Desktop.
鼠标按住的事件处理方式。 From http://segmentfault.com/q/1010000000267088#a-1020000000303243
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