I need to know which function to use in place of the .error()
function.
$('img').error(function() {
$('img').attr('src','img/erro.gif');
});
jquery 3.2.1 does not have this function. How can I resolve this?
I need to know which function to use in place of the .error()
function.
$('img').error(function() {
$('img').attr('src','img/erro.gif');
});
jquery 3.2.1 does not have this function. How can I resolve this?
According to official documentation :
As of jQuery 1.8, the
.error()
method is deprecated. Use.on( "error", tratador)
to attach event handlers to the error event.
That is, change your code to:
$('img').on("error", function() {
$('img').attr('src','img/erro.gif');
});