2
I need to know what function to use instead of the function .error()
.
$('img').error(function() {
$('img').attr('src','img/erro.gif');
});
jquery 3.2.1 does not have this function. How can I fix this?
2
I need to know what function to use instead of the function .error()
.
$('img').error(function() {
$('img').attr('src','img/erro.gif');
});
jquery 3.2.1 does not have this function. How can I fix this?
-1
According to the official documentation:
From jQuery 1.8, the method
.error()
is depreciated. Use.on( "error", tratador)
to attach event handlers to error event.
That is, change your code to:
$('img').on("error", function() {
$('img').attr('src','img/erro.gif');
});
Browser other questions tagged javascript jquery
You are not signed in. Login or sign up in order to post.
i tried this function, but it does not appear the image I put error
– Marcos Sarges
Right, but then your problem becomes another. Create a new question describing the new problem, your current code and more details of your problem (error messages, debugger behavior, code in more detail etc.)
– Pablo Almeida
@Pabloalmeida So the image doesn’t exist or her path is wrong.
– Sam
I re-asked the question, but now this detailed https://answall.com/questions/251097/n%C3%A3o-estou-conseguir-a-imagem-que-demonstrar-erro-usando-jquery
– Marcos Sarges