Skip to content

Instantly share code, notes, and snippets.

@mirzap
Forked from ericchen/keyup_delay.js
Created July 20, 2014 17:04
Show Gist options
  • Save mirzap/b1135fa7d46a20abf9c6 to your computer and use it in GitHub Desktop.
Save mirzap/b1135fa7d46a20abf9c6 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