johnbocook
1/20/2014 - 1:47 AM

Handle Missing Image Errors with jQuery

Handle Missing Image Errors with jQuery

// Hide the image on error
$("img").error(function(){
        $(this).hide();
});

// Change the image to a missing image
$('img').error(function(){
        $(this).attr('src', 'no-image.jpg');
});