Created
August 12, 2014 14:46
-
-
Save MathRivest/c5399eaa31669b4c25d1 to your computer and use it in GitHub Desktop.
Delay Fonction
This file contains 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
$field.on('keyup', function(event){ | |
delay(function(){ | |
alert('Delayed for 1 second') | |
}, 1000); | |
}); | |
var delay = (function(){ | |
var timer = 0; | |
return function(callback, ms){ | |
clearTimeout (timer); | |
timer = setTimeout(callback, ms); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment