JSFiddle - React, Tailwind, and code Playground

by Satpal Singh

HTML

<div id="myDiv">Loading image ...</div>

CSS

#myDiv {
    position:absolute;
    top:0;bottom:0;right:0;left:0;
    margin:auto;
    display:block;
    background-color:black;
    opaciy:0.5;
    filter:alpha(opacity=50);
    padding:5px 10px 5px 10px;
    width:170px;
    height:28px;
    font-size:20px;
    color:white;
}

JavaScript

$('<img src="dasdasd.jpg"/>').load(function(){
    $("#myDiv").hide();
}).error(function(){
    alert('Error occured')
    $("#myDiv").hide();
});

//myDiv will never dissapear beacause dasdasd.as image doesn't exist. How can I check if image doesn't exist then show another message and hide "myDiv" ?