2012-06-28 82 views
0

我有一些數組數據返回從一個圖像鏈接,一些標題文本和鏈接組成的ajax調用。我將這個數組的每個元素都添加到頁面上的div中,方法是使用jQuery append方法並將其淡入。由於執行速度非常快,所有元素同時淡入。我希望每個人都依次淡入。所以,當元素被添加到主div時,淡入然後暫停.each語句約100毫秒,然後添加下一個元素。但我不知道如何做到這一點。有任何想法嗎?這是我的代碼。順序推遲與jquery淡入淡出

jQuery.each(data.themes, function (index){ 

    theme_html = "<div class=\"themePreviewWrap\" id=\"theme_" + index + "\" style=\"display:none;\"><div class=\"themePreview\"><img src=\"" + data.themes[index]['custom_color_screenshot'] + "\" /></div><div class=\"themePreviewButtom\"><div class=\"title\"><b>" + data.themes[index]['title'] + "</b></div><div class=\"link\">" + data.themes[index]['actions'] + "</div></div></div></div>"; 

    jQuery('#themeholder').append(theme_html); 

    jQuery("#theme_" + index).fadeIn(500); 

}); 

回答

0

事情是這樣的:

jQuery("#theme_" + index).delay(index * 1000).fadeIn(500); 
+0

大,非常感謝! –

+0

@geoffswartz:不客氣 – Blaster