JSFiddle - React, Tailwind, and code Playground

by sushanth009

HTML

<input type="text" id="input" />
<div id="div" class="a"></div>

CSS

div {
    height:100px;
    width:100px;
    background:red;
}

.a{
    background:yellow;
}

JavaScript

var timeOut;

$('#input').on('keyup', function () {
    if (timeOut) {
       clearTimeout(timeOut);
       $('#div').removeClass('a');
    }
    timeOut = setTimeout(function () {
        $('#div').addClass('a');
    },1000);
    console.log(timeOut)
});