I have a demo here - http://www.ttmt.org.uk/forum/gallery
And jsfiddle to illustrate my question - http://jsfiddle.net/ttmt/tmyqj/6/
It's just a simple list of images that are floated right off the page.
I would like to load the images sequentially from left to right.
I have done it with this:
$(document).ready(function() {
var lis = $('li').hide();
var i=0;
function displayImg(){
lis.eq(i++).fadeIn(200, displayImg);
}
displayImg();
})
This code works, but I would like to load one image at a time, so I need to check if an image has loaded before loading the next one.
I tried with this but it only loads the very first image.
$(document).ready(function() {
var lis = $('li').hide();
var i=0;
function displayImg(){
lis.eq(i).fadeIn(200, checkLoad);
}
function checkLoad(){
if(lis.eq(i).complete){
i++;
displayImg();
}else{
alert('img not load');
}
}
displayImg();
})
How can I check if an image has loaded before loading the next image?