你可以簡單地使用這一功能擴展jQuery的:
$.fadeInNext = function(next){
next.fadeIn(function(){
$.fadeInNext($(this).next());
});
}
$.fn.fadeInEach = function(){
this.eq(0).fadeIn(function(){
$.fadeInNext($(this).next());
});
};
$('#fade p').hide().fadeInEach();
這應該工作。Example
更新:
淡出新信透水一個沒落之後:
$.fadeInNext = function(next) {
next.fadeIn(function() {
$(this).fadeOut(function(){
$.fadeInNext($(this).next());
});
});
}
$.fn.fadeInEach = function() {
this.eq(0).fadeIn(function() {
$(this).fadeOut(function() {
$.fadeInNext($(this).next());
});
});
};
$('#fade p').hide().fadeInEach();
Example
淡入新的信而以前是還是淡出:
CSS:
#fade {
position: relative;
}
#fade p {
position: absolute;
}
的JavaScript:
$.fadeInNext = function(next) {
next.fadeIn(function() {
$(this).fadeOut();
$.fadeInNext($(this).next());
});
}
$.fn.fadeInEach = function() {
this.eq(0).fadeIn(function() {
$(this).fadeOut();
$.fadeInNext($(this).next());
});
};
$('#fade p').hide().fadeInEach();
Example
他們應該淡出嗎? – jigfox 2010-08-28 11:06:23