html
<img src="images/true.jpg" onerror="whenError(this)"> |
js
function whenError(a){ a.onerror=null; a.src='images/error.png'; console.log("图片出错的时候调用默认图片") }; |