I am trying to detect when a group of images has loaded within a div.
if($("#venues-page").get(0)) {
var img = $('#venues-page .venues img');
var length = img.length;
img.load(function(){
length--;
console.log(length);
if(length === 0){
console.log("here");
$(".lattice").fadeIn(1000);
$("#venues .venue a").css("display", "block");
$("#venues-page .venues img").not('.lattice').fadeIn(500);
}
});
}
This seems to work fine when the images are cached in the browser, however if the user has not visted the site before the images never seem to all load without refresh after refresh after refresh.
Is there a better to make sure all the images are loaded within a div, and the do stuff based on that?