2015-08-18 98 views
0

我想添加淡入此代碼之間的這些元素淡入淡水btw兩個元素jquery

有些幫助嗎?

$("#example p:first").css("display", "block"); 

jQuery.fn.timer = function() { 
    if(!$(this).children("p:last-child").is(":visible")){ 
     $(this).children("p:visible") 
      .css("display", "none") 
      .next("p").css("display", "block"); 
    } 

} 

window.setInterval(function() { 
    $("#example").timer(); 
}, 1000); 

回答

1
$('#example p').each(function(index) { 

$(this).delay((index+1)*1000).fadeIn(500); 

}); 

演示:http://jsfiddle.net/b0we0g3h/1/

你不需要setInterval的,在這種情況下,你可以使用延時():

附:如果你想讓第一個p標籤沒有延遲地出現,只需使用索引,而不是索引+ 1。