Why does this attempt at preloading images with jQuery not work?
- by Eric
Current I have this code:
var imgCount = 36;
var container = $('#3D-spin');
var loaded = 0;
function onLoad()
{
alert(loaded);
loaded++;
if(loaded >= imgCount)
{
alert('yay');
}
}
for(var i = imgCount-1; i >= 0; i--)
{
container.prepend(
$('<img>')
.one('load', onLoad)
…