我在 stackoverflow 上找到了答案来构建这个。我想要实现的目标:
对于 .element-wrapper
中的每个 .element
添加类 .visible
,延迟 1000ms 。
$('.element-wrapper').children('.element').each(function(i) {
var $item = $(this);
setTimeout(function() {
$('.element').addClass('visible');
}, 1000 * i);
});
最佳答案
实际上你几乎是对的......只需更改下面一行以使其对当前包装器上下文敏感:
$('.element-wrapper').children('.element').each(function(i) {
var $item = $(this);
setTimeout(function() {
$item.addClass('visible'); // Change this line.
}, 1000 * i);
});
关于javascript - .each .children() 元素有延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40547329/