XHanch Studio Log in | Register | Cart

Forum

Notifications
Clear all

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

1 Posts
1 Users
0 Likes
1,125 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

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.

// 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();
});
 
Posted : 25/12/2011 6:37 am
Share:

× Close Menu