Skip to content

Instantly share code, notes, and snippets.

@thedapifer
Forked from johnbocook/missing_images.js
Created January 16, 2018 03:53
Show Gist options
  • Select an option

  • Save thedapifer/48c8bcce1d489bb8391dbb9467cd46b7 to your computer and use it in GitHub Desktop.

Select an option

Save thedapifer/48c8bcce1d489bb8391dbb9467cd46b7 to your computer and use it in GitHub Desktop.
Use jQuery to deal with missing images
// Hide the image on error
$("img").error(function(){
$(this).hide();
});
// Change the missing image to a default image
$('img').error(function(){
$(this).attr('src', 'no-image.jpg');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment