Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active October 26, 2022 13:19
Show Gist options
  • Save vielhuber/4ed60232d67d81752db1d79030115438 to your computer and use it in GitHub Desktop.
Save vielhuber/4ed60232d67d81752db1d79030115438 to your computer and use it in GitHub Desktop.
delay for input type change ajax autocomplete #js
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$('input').keyup(function() {
delay(function(){
alert('foo');
}, 1000 );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment