(function($){ const debounce = (func, wait) => { let timeout; return function(...args) { const context = this; clearTimeout(timeout); timeout = setTimeout(() => func.apply(context, args), wait); }; }; const searchBox = $('input[name="s"]'); const doSearch = function() { $(this).trigger('keyup'); // Kích hoạt sự kiện gốc }; searchBox.off('keyup'); // Gỡ xử lý cũ searchBox.on('keyup', debounce(doSearch, 300)); // Gắn debounce })(jQuery);
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.