I want to preload these 4 images. I tried this:
<img src="img/1.jpg" style="display:none">
<img src="img/1a.jpg" style="display:none">
<img src="img/1b.jpg" style="display:none">
<img src="img/1c.jpg" style="display:none">
It didn't work so I tried this instead:
new Image().src = "img/1.jpg";
new Image().src = "img/1a.jpg";
new Image().src = "img/1b.jpg";
new Image().src = "img/1c.jpg";
The JS method worked with the background but not with these.
Try utilizing
$.Deferred()
,.queue()
Instead of setting the images themselves to
display: none;
, set it on the container.CSS:
HTML:
This never actually appends anything to the DOM, I used an array to keep references of the created images, and pass them to an optional callback