JSFiddle - React, Tailwind, and code Playground
by ponyspy
HTML
<input type="text" placeholder='поиск'>
<div class="res"></div>
JavaScript
function debounce(f, ms) {
var lastCall;
return function() {
if (!lastCall || new Date - lastCall >= ms) {
lastCall = new Date;
return f.apply(this, arguments);
}
}
}
function cl() {
var val = $(this).val();
$('.res').text(val);
}
var cl = debounce(cl, 800);
$('input').on('keyup change', cl);