Result jQuery$(document).ready(function() { //画像にclassを付加 $('img').addClass('miss'); //画像が見つからないときにエラーイベント発生 $('img.miss').error(function() { //置換処理 $(this).attr({ src: 'http://example.com/no-images.jpg', alt: 'none image', style:'border: 1px solid #eee;width:150px;height:150px;margin:25px;' }); }); });html<img src="nothing.jpg" />viaUse Custom Missing Image Graphics Using jQuery
![指定された画像が存在しないときに別の画像に置換する](https://cdn-ak-scissors.b.st-hatena.com/image/square/b6b1c87ada2ad66409793e3653c810e333009609/height=288;version=1;width=512/http%3A%2F%2Fkachibito.net%2Fwp-content%2Fuploads%2F2019%2F12%2Fsite-icon.png)