I want to change to img error text.

Asked 1 years ago, Updated 1 years ago, 122 views

If it doesn't load normally when loading the img, I want to change it to text, but I only change the image with an error I'd like to.

If multiple images are loaded into a table,

$(".a img").error(function() { $("Error Images").addClass("error"); });

$(".error").replaceWith("<p> Image Error</p>");

I want to show it like this, but I don't know how to select only the image with the error.

I'd appreciate it if you could give me your opinion.

jquery img

2022-09-21 17:12

1 Answers

Originally, I was going to recommend Lazy load, but Give on error event callback to each image and it will be solved at once. It's a secret that I just found out that there's an event like this.

Please refer to DEMO.


2022-09-21 17:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.