JSFiddle - React, Tailwind, and code Playground

by Ehsan Sajjad

HTML

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

JavaScript

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);
    });
});