在一秒之内点击多次, 只触发一次事件, 比如避免多次点击登录按钮, 重复发请求; undersore 也有 _debounce这个函数.
var a = document.getElementById('a'); a.addEventListener('click', bound(function(){ console.log(2) },1000)) function bound(fn, time){ var st = null; return function(){ if(!st){ fn(); st = new Date(); } if(new Date - st >= time){ fn(); st = new Date(); } else{ //不到时间不执行 } } }