Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A debounce timeout trigger for typing in an input. The example is in jQuery, but this works with any event/listener.
$('#input').on('keyup', function() {
// do an ajax save when this input is changed
var val = this.value;
// clear the timeout so we dont fire in succession
clearTimeout(this.delayer);
this.delayer = setTimeout(function () {
console.log(val);
}, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment