js节流防抖
//节流防抖函数 function debounce(fun, delay) { return function (args) { let that = this let _args = args clearTimeout(fun.id) fun.id = setTimeout(function () { fun.call(that, _args) }, delay) } } //触发 var debounceAjax = debounce(ajax,500); //500毫秒延时 $('#scbar_txt').on('keyup', function (e) { debounceAjax(key); }); /执行 function ajax(key) { // }