jquery image preload and error detection -


Long listener, first time collar ...

Preload an array of images I am trying to do and to show any missing people before they are shown. I am currently using a standard image loader that works fine but does not help broken links

preload function

 < Code> function preload (arrayOfImages) {$ (ArrayOfImages) .each (function () {$ ('& lt; img / & gt;') [0] .src = this;}); }  

Usage

  preload ([image.jpg]);  

How can I use jQuery to preload the set of images and replace broken links with a static link before it can be used on the page ? The idea is that the missing image '?' Is ever visible.

Thanks

You can use jQuery error ()

  $ ('& lt; img / & gt;'). Error (function ()) {/ code> $ (this) .attr ("src", "your_static_link_here");});  

Comments