Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
Last active May 2, 2016 11:58
Show Gist options
  • Save swapnilshrikhande/18cd0f88ced26b569e8a21d200c6f82a to your computer and use it in GitHub Desktop.
Save swapnilshrikhande/18cd0f88ced26b569e8a21d200c6f82a to your computer and use it in GitHub Desktop.
var delay = (function(){
var timer = 0;
return function(callback,param, ms){
clearTimeout (timer);
timer = setTimeout(function(){
callback(param);
}, ms);
};
})();
//example
$('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