Posted By

coder_ on 02/22/11


Tagged

jquery img broken


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

dubogii
happynuclear


Broken image detection with jquery


 / Published in: jQuery
 

URL: http://css-tricks.com/snippets/jquery/better-broken-image-handling/

  1. // Replace source
  2. $('img').error(function(){
  3. $(this).attr('src', 'missing.png');
  4. });
  5.  
  6. // Or, hide them
  7. $("img").error(function(){
  8. $(this).hide();
  9. });

Report this snippet  

You need to login to post a comment.