我有以下功能。长话短说,我想向 4 个 div 应用 init
类。 init
类本质上显示了 4 个 div。
它按预期工作,但是它同时显示所有 4 个 div,这不是我想要的。我想显示 1 个 div,然后是下一个,然后是下一个,等等。
我哪里出错了?
$('.campaign-item').waypoint({
handler: function() {
var $this = $(this);
$this.each(function(i) {
setTimeout(function() {
$this.addClass('init');
}, i * 500 );
});
},
offset: '60%'
});
最佳答案
$('.campaign-item').each(function (i) {
var $this = $(this);
$this.waypoint({
handler: function() {
setTimeout(function() {
$this.addClass('init');
}, i * 500 );
},
offset: '60%'
});
});
关于javascript - $.each 函数显示每个 DIV,一次一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23435582/