I have this code that displays a different image in place of a broken image link. The problem is that the script changes not only "damaged" images, but also images that display without a problem. How can I modify the code below?
$("img").each(function () {
if (
(typeof this.naturalHeight != "undefined" &&
this.naturalHeight == 0 &&
this.naturalWidth == 0) ||
this.readyState == "uninitialized"
) {
$(this).attr(
"src",
"http://some-photo.blabla.png"
);
}
});
I'm taking my first steps in programming.
Modifying the code so that it only fixes broken links, not all of them.
Your code should be executed after the page is fully loaded