2012-03-07 83 views
0
<img id="Img1" class="photoBox" src="Images/DisplayImageById.ashx?number=1&userName=<%=Page.User.Identity.Name %>"/> 
     <img id="Img2" class="photoBox" src="Images/DisplayImageById.ashx?number=2&userName=<%=Page.User.Identity.Name %>"/> 
     <img id="Img3" class="photoBox" src="Images/DisplayImageById.ashx?number=3&userName=<%=Page.User.Identity.Name %>"/> 
     <img id="Img4" class="photoBox" src="Images/DisplayImageById.ashx?number=4&userName=<%=Page.User.Identity.Name %>"/> 
     <img id="Img5" class="photoBox" src="Images/DisplayImageById.ashx?number=5&userName=<%=Page.User.Identity.Name %>"/> 

我一直在尋找一種方法來顯示旋轉圖標,直到圖像加載而不使用ajax?我正在研究如何使用ajax加載圖像,但它不會很好,所以我開始尋找一種無ajax的方法。那可能嗎?Show without image ajax

謝謝你的幫助。

回答

1

選中此項。這是使用jQuery的load事件,當一個特定的元素被加載,你的情況告訴,img

http://jsfiddle.net/blackpla9ue/uJhCt/1/

$(function(){ 
    $('div img').each(function(){ 
    var thisImage = $(this); 
    thisImage.hide(0) 
      .load(function(){ 
       $(this).show(); 
      }); 
}); 

注意做這將工作,如果你把你的代碼中$(document).ready(function(){ ...});