jQuery code to handle broken (not found) images in webpage
The error event is sent to elements, such as images, that are referenced by a document and loaded by the browser. It is called if the element was not loaded correctly. Code is self explanatory and it is based on jQuery 1.7.2 version.
$(document).ready(function() { var backup_Img = 'images/noimage.gif'; $("img").on('error', function(){ $(this).prop('src', backup_Img); }); });
Note:
So error event may not work if you are testing it using file:// protocol. Instead, host it on web server and access using HTTP protocol.
Feel free to contact me for any help related to jQuery, I will gladly help you.