Remove broken placeholders when images don't load
Images that don't load can sometimes leave an ugly red [X] placeholder. This jQuery snippet will remove all instances of images that don't load. It even takes into account that IE will only produce a single error for each unique src attribute.
$('img').error(function(){
$('img[src="'+$(this).attr('src')+'"]').remove();
});
It's safer to completely remove the broken image from the DOM as the display and visibility CSS properties work inconsistently across browsers.
Written by Roger Vandawalker
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#