JSFiddle - React, Tailwind, and code Playground

HTML

<div id="BGyes">BG Yes</div>
<div id="BGno">BG No</div>

<p>Results</p>
<div id="result"></div>

CSS

p {font-family:arial,sans-serif;line-height:1.2em;border-bottom:solid 1px #111;color:#111;margin:5px 0;}

#BGyes {background:#ddd url('http://lottabruhn.typepad.com/lotta_bruhn_illustration/images/2008/01/18/elephant_pattern.gif') 
repeat 0 0;height:44px;}

#BGno {background:#ddd url('http://doesnotexist.com/img/DOES_NOT_EXIST.png') repeat 0 0;height:44px;}

JavaScript

//example based off http://www.rgagnon.com/jsdetails/js-0083.html
var imgSrc1 = "http://lottabruhn.typepad.com/lotta_bruhn_illustration/images/2008/01/18/elephant_pattern.gif";
var imgSrc2 = "http://doesnotexist.com/img/DOES_NOT_EXIST.png";
var img1 = new Image();
var img2 = new Image();

img1.onerror = handleImgError;
img2.onerror = handleImgError;

img1.onload = handleImgLoad;
img2.onload = handleImgLoad;
    
function handleImgError(e) {
    $result = $('#result');
    $result.html($result.html() + this.src + " <b>can't be loaded</b>" + "<br />");
}
function handleImgLoad(e) {
    $result = $('#result');
    $result.html($result.html() + this.src + " <b>is loaded</b>" + "<br />");
}

img1.src = imgSrc1;
img2.src = imgSrc2;