How to detect broken image and replace with another?

前端 未结 3 791
不思量自难忘°
不思量自难忘° 2021-02-10 17:46

I have a page which displays lots of images from different remote servers. http://example.com/img/email_star0.png\' height=\'150\' />

Now suppose this image is not prese

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-10 18:24

    You can use the 'onerror' attribute directly in the image tag:

    
    

提交回复
热议问题