版权声明:学习交流。。 https://blog.csdn.net/qq_38881495/article/details/83824186
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>修复错误图片</title>
</head>
<body>
<img src="error.png" alt="" class="surface_plot" onerror="src='error.png'" /> <!-- 第一种img直接替换 -->
<img src="error.png" alt="" onerror="nofind();" /> <!-- 第二种调用方法 -->
</body>
<script>
function nofinds(){
var img=event.srcElement;
img.src="替换的图片路径";
img.onerror=null; //控制不要一直跳动
};
$("img").error(function(){ //第三种替换
$(this).attr('src','替换的图片路径');
});
</script>
</html>