如何知道图像是否无法加载javascript?

Sag*_*gar 1 html javascript asp.net jquery web

有没有办法知道某些图像无法在jquery/javascript中加载到网页中.

xda*_*azz 5

使用:.error()

$('img').error(function() {
  alert('Failed to load the image with src: ' + $(this).attr('src'));
});
Run Code Online (Sandbox Code Playgroud)