Skip to content

Instantly share code, notes, and snippets.

@johnbocook
Created January 20, 2014 01:47
Show Gist options
  • Select an option

  • Save johnbocook/8513638 to your computer and use it in GitHub Desktop.

Select an option

Save johnbocook/8513638 to your computer and use it in GitHub Desktop.
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');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment