如何判断图像是否在html img标记中加载失败(404未找到,或其他4xx或5xx错误),并通过jquery回调进行报告?
$('img').error(function(){
//...
});
文档
文档中的一个示例:
<img alt="Book" id="book" />
$('#book')
.error(function() {
alert('Handler for .error() called.')
})
.attr("src", "missing.png");