provola provola - 11 days ago 5
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.