防抖

#html

    <input type="text " id="ip">

##javascript

var oInp = document.getElementById('ip');
  var oInp = document.getElementById('ip');
  var timer = null;
  function ajax(e) {
    console.log(e, this.value);
  }
            
  oInp.oninput = function(e) {
     var _self = this, _arg = arguments;
    clearTimeout(timer);
    timer = setTimeout(function(){
       ajax.apply(_self,_arg);
    },1000)
}

  

原文地址:https://www.cnblogs.com/YangJonathan/p/11223644.html