jQuery: gestire le immagini mancanti

Con jQuery possiamo gestire facilmente le immagini mancanti.

jQuery di Gabriele Romanato

Con jQuery possiamo gestire facilmente le immagini mancanti.

Possiamo sia nascondere che sostituire l'immagine mancante con un segnaposto:


(function( $ ) {
  $(function() {
     $( "img" ).on( "error", function() {
        $( this ).attr( "src", "/images/placeholder.png" );
     });
     $( "img" ).on( "error", function() {
        $( this ).hide();
     });
  });
})( jQuery );

Commenti