JSFiddle - React, Tailwind, and code Playground
HTML
<div id="wrapper"></div>
CSS
#wrapper{
width: 400px;
height: 300px;
}
.noImg{
background:url('http://punchmujafrabadcommunity.com/admin/img/noimg.jpg');
}
JavaScript
$(function(){
$('#wrapper').append('<img onerror="replaceEmptyImage($(this))" src="missing.photo.jpg">')
});
replaceEmptyImage = function($img) {
console.debug('ciao');
$img.parent().addClass('noImg');
$img.remove();
};