JSFiddle - React, Tailwind, and code Playground

by GMK Hussain

HTML

<h2>Better Broken Image Repalce with No Image </h2>

<div class="pic">
    <img src="notfound.jpg" />
</div>

CSS

.pic {
    border:1px solid #ccc;    
}

.pic img { width: 100%; }

JavaScript

// Replace source
$('img').error(function(){
   // $(this).attr('src', 'http://www.skypeassets.com/content/dam/scom/images/newhome/iPhone_white_813x1114.png');
    $(this).attr('alt', 'NO IMAGE');
    
});

// Or, hide them
$("img").error(function(){
        $(this).hide();
});