1
如何判斷圖像是否在html img標籤中加載失敗(404未找到或其他4xx或5xx錯誤)並通過jquery回調進行報告?如何判斷圖像是否在html img標籤中加載失敗?
如何判斷圖像是否在html img標籤中加載失敗(404未找到或其他4xx或5xx錯誤)並通過jquery回調進行報告?如何判斷圖像是否在html img標籤中加載失敗?
$('img').error(function(){
//...
});
從文檔的一個例子:
<img alt="Book" id="book" />
$('#book')
.error(function() {
alert('Handler for .error() called.')
})
.attr("src", "missing.png");
http://stackoverflow.com/questions/1977871/check-if-an-image-is-loaded-no-錯誤 - 在JavaScript的 –