Skip to content

Instantly share code, notes, and snippets.

@yasircs4
Created December 8, 2016 08:49
Show Gist options
  • Save yasircs4/262a816989c7992b677ee4dd9f603777 to your computer and use it in GitHub Desktop.
Save yasircs4/262a816989c7992b677ee4dd9f603777 to your computer and use it in GitHub Desktop.
jQuery when Error Do same things
// @link https://css-tricks.com/snippets/jquery/better-broken-image-handling/
// Replace source
$('img').error(function(){
$(this).attr('src', 'missing.png');
});
// Or, hide them
$("img").error(function(){
$(this).hide();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment