Image load error 2
For div background image.
by Abhijeet Deshmukh
HTML
<div style="height:300px; width:300px;background:url(http://www.gettyimages.in/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg);object-fit:contain;border:2px solid black"></div>
JavaScript
$('<img/>').attr('src', 'http://www.gettyimages.in/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg').load(function () {
$(this).remove();
alert('success');
}).on('error', function () {
alert('error');
});