JSFiddle - React, Tailwind, and code Playground

by Ehsan Sajjad

HTML

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

JavaScript

var Timeout; // initialize a variable
$(document).ready(function () {
    $('input#input').keypress(function () {
        var txtbox = $(this); // copy of this object for further usage

        if (Timeout) //check if timeout not null clear it
        clearTimeout(Timeout);
        Timeout = setTimeout(function () { // set timeout for 1 second again
            alert(txtbox.val());
        }, 1000);
    });
});