Last active
May 2, 2016 11:58
-
-
Save swapnilshrikhande/18cd0f88ced26b569e8a21d200c6f82a to your computer and use it in GitHub Desktop.
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 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