Skip to content

Instantly share code, notes, and snippets.

@GiovanniK
Forked from ericchen/keyup_delay.js
Created June 11, 2014 20:28
Show Gist options
  • Save GiovanniK/aa1b02abd9c58462c69c to your computer and use it in GitHub Desktop.
Save GiovanniK/aa1b02abd9c58462c69c to your computer and use it in GitHub Desktop.
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$('input').keyup(function() {
delay(function(){
alert('Time elapsed!');
}, 1000 );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment