Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何知道是否在javascript中加载图像失败?_Javascript_Jquery_Asp.net_Html_Web - Fatal编程技术网

如何知道是否在javascript中加载图像失败?

如何知道是否在javascript中加载图像失败?,javascript,jquery,asp.net,html,web,Javascript,Jquery,Asp.net,Html,Web,有没有办法知道jquery/javascript中的某些图像无法加载到网页中。使用: $('img').error(function() { alert('Failed to load the image with src: ' + $(this).attr('src')); }); 用法: $('img').error(function() { alert('Failed to load the image with src: ' + $(this).attr('src')); })

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

使用:

$('img').error(function() {
  alert('Failed to load the image with src: ' + $(this).attr('src'));
});
用法:

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