jQuery has a function to handle this, take a look at .error()
So, for example, you can attach a .error()handler to all images and display something else if there is an error, for example, the source no longer exists:
$('img').error(function() {
$(this).hide();
}).attr("src", "missing.jpg");
Here is a demo
source
share