Handling Broken Image

Submitted by:Tim Kelly

Date added:09 January, 2013

Category:jQuery

Better way to handle Broken Image. Missing images will either just display nothing, or display a [ ? ] style box.

Tags: handle broken image

Code Snippet:

// Replace source
$('img').error(function(){
$(this).attr('src', 'missing.png');
});

// Or, hide them
$("img").error(function(){
$(this).hide();
});
 
 

Comments