$next.on('click',function(){
//清除定时器
clearInterval(t);
//执行一次下一张轮播图的播放
setTimeout(next);
//执行一次下一张轮播图的播放后执行轮播
setTimeout(t=window.setInterval( next, delay ),delay);
});
How to add a limit to this click event, and you have to wait 5 seconds before clicking
伊谢尔伦2017-06-26 11:00:07
var overtime = true;
$next.on("click",function(){
if(!overtime){
return;
}
console.log("click success");
overtime = false;
});
var catchTimer = setInterval(function(){
overtime = true;
},5000);
滿天的星座2017-06-26 11:00:07
function throttle (func, duration) {
let start
return function () {
if (!start) start = Date.now()
else if (start + duration > Date.now()) return
func.apply(this, arguments)
}
}
$next.on('click', throttle(function () {
// Your code
}, 5000))