Trigger a function if TYPING STOPPED

HTML


<input type="text" id="username" />

JS

var timeoutReference;
$(document).ready(function() {
$('input#username').keypress(function() {
var _this = $(this); // copy of this object for further usage
if (timeoutReference) clearTimeout(timeoutReference);
timeoutReference = setTimeout(function() {
alert(_this.val());
}, 3000);
});
});

JS FIDDLE

Published by

Shiyam

My passion became my profession , I'm a driven, energetic and proactive tech professionally. I consider myself an engagement professional, as I don't simply provide solutions, I create them. I am a continuous learner – always looking for new technologies, in my spare time I search Google for the latest trends . I like to think of myself as a futurist and I'm a Full Stack JavaScript Developer.

Leave a comment