How to automatically repair damaged images by jQuery
Editor to share with you how jQuery automatically repair damaged images, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Automatically repair damaged images
Replacing broken image links one by one is very painful. However, the following simple code can help you:
$('img') .on (' error', function () {if (! $(this) .hasClass ('broken-image')) {$(this) .prop (' src', 'img/broken.png'). AddClass (' broken-image');}})
Even if there are no broken links, adding this piece of code won't cost you anything.
The above is all the contents of the article "how to repair damaged images automatically by jQuery". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!