jQuery each()有一个延迟
问题描述:
所以,我想要一个元素淡入并等待半秒钟,然后淡出下一个... ...
So, I would like an element to fade in and wait half a second, then fade the next in etc...
我的代码:
$('.comment').each(function() {
$(this).css({'opacity':0.0}).animate({
'opacity':1.0
}, 450).delay(500);
});
我显然做了一件非常愚蠢的事......(我希望)......我的问题是:这甚至可能吗?如果没有 - 有人能指出我正确的方向吗?
I'm obviously doing something really silly.... (I hope)... My question is: Is this even possible? if not - can anyone point me in the right direction?
感谢你!
答
或者,像这样:
$.each($('.comment'), function(i, el){
$(el).css({'opacity':0});
setTimeout(function(){
$(el).animate({
'opacity':1.0
}, 450);
},500 + ( i * 500 ));
});