<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" id="input">
<script>
const oInput = document.getElementById('input');
function ajax(e) {
console.log(this.value, e);
}
function debounce(handler, delay) {
let timer = null;
return function() {
const _args = arguments;
clearTimeout(timer);
timer = setTimeout(() => {
handler.apply(this, _args);
}, delay)
}
}
// oInput.oninput = ajax;
oInput.oninput = debounce(ajax, 1000)
</script>
</body>
</html>