Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>This example demonstrates how to assign an "onerror" event to an img element.</p>

<img src="http://www.w3schools.com/jsref/image.gif" onerror="myFunction()">

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "The image could not be loaded.";
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy