[How to] Check for broken images and overcome them with jQuery

Started by Xhanch Studio, December 24, 2011, 11:37:40 PM

previous topic - next topic
Go Down

Xhanch Studio

In jQuery, you can simply utilize the error event to find broken images. To overcome them, you may replace them with an informative image or simply hide them.

Code Select
// To replace broken images with an informative image
$('img').error(function(){
        $(this).attr('src', 'image-not-found.jpg');
});

// To hide broken images
$("img").error(function(){
        $(this).hide();
});
Best Regards,
Susanto B.Sc
----------------------------------------------------------------------------
Web development services, WordPress plugin and theme development, PSD to XHTML conversion - http://xhanch.com
Read free manga online - http://authrone.com

Go Up