Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何判断图像是否在 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");