Skip to content

Hide or Replace Missing Images

  • by

With jQuery you can watch for the error when the browser can't find an image - then do what you want with it 🙂

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

//or 
$('img').error(function(){ 
    $(this).hide(); 
});

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

s2Member®