jQuery/JavaScript to replace broken images

I have a web page that includes a bunch of images. Sometimes the image isn’t available, so a broken image is displayed in the client’s browser.

How do I use jQuery to get the set of images, filter it to broken images then replace the src?


–I thought it would be easier to do this with jQuery, but it turned out much easier to just use a pure JavaScript solution, that is, the one provided by Prestaul.

32 s
32

Leave a Comment