我想在jQuery each循环的每次迭代后添加暂停,但我似乎无法弄清楚如何实现。
这个有什么可行的方法吗?
$(".item").each(function(i){
var el = this;
var timer = setTimeout(function(){
$(el).trigger("click");
}, 500);
});
这个代码并不是每半秒触发一次,而是一次性地触发所有项目的点击事件。
我想要类似于以下伪代码的效果:
$(".item").each(function(i){
$(this).trigger("click");
wait(500); // wait a half second before the next iteration
});
这个有什么可行的方法吗?