2016-01-29 125 views

回答

1

您可以使用load函數使用jQuery加載圖像。

例如:

$("<img src='pathtoimg/img.jpg'>").load(function(){ 
    //any code in here will run after the image has successfully loaded. 
}); 
+0

我想顯示一個加載器befor背景圖像越來越負載。 – kalles

1

嘗試這樣的:

$(document).ready(function(){ 
    $('#imgLoader').show(); 
    $('#imgMain').load(function(){ 
    $('imgLoader').hide(); 
    }); 
}); 

這裏imgLoader是你想要的主圖像(imgMain)加載時顯示圖像。