Using JQuery .each function() yet it is operating on all elements at the same time. Instead I want it to be sequential. So operating开发者_运维问答 on one function once complete the second etc.. etc..
$('#fader').children().hide();
$('#fader').children().each(function(){
$(this).fadeIn(2000,function(){
$(this).delay(4000);
$(this).fadeOut(2000);
});
});
You can do it with a recursive function like this:
function fader(elm) {
elm.fadeIn(2000, function(){
elm.delay(4000);
elm.fadeOut(2000, function() {
if (elm.next()) {
fader(elm.next());
}
});
});
}
$('#fader').children().hide();
fader($('#fader').children(':first'));
精彩评论