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的 –