Inputting a default image in case the src attribute of an html

后端 未结 22 2441
渐次进展
渐次进展 2020-11-22 16:02

Is there any way to render a default image in an HTML tag, in case the src attribute is invalid (using only HTML)? If not, what would

22条回答
  •  感情败类
    2020-11-22 16:28

    The above solution is incomplete, it missed the attribute src.

    this.src and this.attribute('src') are NOT the same, the first one contains the full reference to the image, for example http://my.host/error.jpg, but the attribute just keeps the original value, error.jpg

    Correct solution

    
    

提交回复
热议问题