我有一個網站,顯示大量的圖片。沒有顯示它們並觀察它加載,有沒有辦法在加載完成後淡入其中?有點新的jQuery和JavaScript的美妙世界。當完成加載每個單獨的DIV與圖像時jQuery淡入?
現在我從中調用MySQL服務器並獲取最新的圖像的PHP文件中獲取數據。它只是返回的HTML大塊顯示:
// If the user clicks the logo
$("#logo").click(function() {
$("#right_bar_wrapper").animate({ height: 'toggle', opacity: 'toggle' }, '200');
var thePostData = "username=c";
$.ajax({
type: "POST",
url: "http://myflashpics.com/v2/process_newsfeed.php",
data: thePostData,
success: function(theRetrievedData) {
document.getElementById('right_bar_wrapper').innerHTML = theRetrievedData;
$("#right_bar_wrapper").fadeIn("200");
}
});
});
這裏是其中一個DIV看起來像一個包含每個圖像:
<div class='sidebar_image_box_newsfeed'>
<div class='sidebar_image_box_newsfeed_user_info makeProfileAppear' id='user_coultonvento'><img src='http://myflashpics.com/get_image.php?short_string=kmdp&size=thumbnail' />TheAmazingCoultoniusTheFourneeth...</div>
<img src='http://myflashpics.com/get_image.php?short_string=6v9o&size=big' id='image_6v9o' class='makePictureBig' style='width: 180px;' />
<div class='sidebar_image_box_newsfeed_user_info_comments' style='float: right; margin-top: -1px; margin-left: 20px; display: none;' id='bigpicture_comment_6v9o'>9</div>
<div class='sidebar_image_box_newsfeed_caption'>Usama bin laden? I believe that's a typo, Fox. </div>
<div class='sidebar_image_box_newsfeed_user_info_comments' id='littlepicture_comment_6v9o'>9</div>
<div style='clear: both;'></div>
</div><div class='sidebar_image_box_newsfeed'>
<div class='sidebar_image_box_newsfeed_user_info makeProfileAppear' id='user_BrandonVento'><img src='http://myflashpics.com/get_image.php?short_string=e4r7&size=thumbnail' />Brandon Vento</div>
<img src='http://myflashpics.com/get_image.php?short_string=o1sk&size=big' id='image_o1sk' class='makePictureBig' style='width: 180px;' />
<div class='sidebar_image_box_newsfeed_user_info_comments' style='float: right; margin-top: -1px; margin-left: 20px; display: none;' id='bigpicture_comment_o1sk'>9</div>
<div class='sidebar_image_box_newsfeed_caption'></div>
<div class='sidebar_image_box_newsfeed_user_info_comments' id='littlepicture_comment_o1sk'>9</div>
<div style='clear: both;'></div>
</div>
當然,這淡入但用戶看它加載。
什麼會做的最好的方式是這樣?
謝謝,
庫爾頓
看看你有什麼用看它加載意思? – Nick 2011-05-04 04:16:00
@Nick:觀看圖片加載。在谷歌瀏覽器中,您會看到圖像的頂部,然後慢慢地開始查看圖像的其餘部分。把它隱藏起來,直到它被加載並讓它淡入? – iosfreak 2011-05-04 04:17:45