preload = function() {
var imgList = [];
var imgArr = [];
var imageSize = element.find('img').size();
var loadImgList = element.find('img');
for(i=0; i<imageSize;i++){
imgArr.push($(loadImgList[i]).attr('src'));
}
var total = imgArr.length;
var loaded = 0;
for(var i in imgArr) {
imgList.push($("<img />")
.attr("src", imgArr[i])
.load(function() {
loaded++;
if(loaded == total) {
element.find('.loader').fadeOut('slow');
init();
}
})
);
}
}
preload = function() { var imgList = []; var imgArr = []; var imageSize
Share
I don’t know whether this solves your problem since you’re not saying what exactly doesn’t work, but you need to set
srcafter you define the handler for theonloadevent.Also, note that
.load()has numerous issues when used with images as outlined in the jQuery docs: