provola provola - 1 month ago 10
Javascript Question

Jquery .error method replacement

$(this).attr('src', 'missing.png');

// Or, hide them

This code does'nt work because .error has been removed in jquery 3.x.
What Jquery method or Javascript method can I use to test for broken image?


Use on:

$('img').on("error", function(){
        $(this).attr('src', 'missing.png');

See the jQuery 3 migration guide.