画像が存在しない場合の、代替画像 javascript

inline scriptを使用

画像が存在しない場合 代替画像を表示

画像が存在する場合、存在画像を表示

http://www.example.com/images/image.jpg は、存在しない画像

source

画像が存在しない場合 代替画像を表示

<img src="http://www.example.com/images/image.jpg" onError="this.onerror=null;this.src='http://www.tenman.info/images/pen.jpg';" />

画像が存在する場合、存在画像を表示

<img src="http://tenman.info/labo/css/files/copy-narukokyo2.jpg" onError="this.onerror=null;this.src='http://www.tenman.info/images/pen.jpg';" />

http://stackoverflow.com/questions/92720/jquery-javascript-to-replace-broken-images


新着記事

コメントは受け付けていません。