Created
April 11, 2020 14:56
-
-
Save vankasteelj/2aea6401dc9bca8a8f169ee8b11265c9 to your computer and use it in GitHub Desktop.
Jquery click & hold
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 timeOut = 0; | |
$('.button').on('mousedown', function(e) { | |
console.log('click'); | |
//start hold | |
var i = 0; | |
timeOut = setInterval(function(){ | |
console.log('hold for', i++); | |
}, 150); | |
}).bind('mouseup mouseleave', function(e) { | |
clearInterval(timeOut); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment