views:

105

answers:

1
var nowCount = 0;
$("img").load(function(){
imgCount++;
if (nowCount == imgsCount)
do something ... 
});

imgsCount :: the number of images that i want to load

1- is this code compatible with all browsers ?
2- how can i know if an image failed to load ?

+2  A: 

There is a lot of suspicious code here:

  • Img**s**Count vs. ImgCount
  • what is nowCount supposed to do?
  • Are you sure about the unload event for the IMG tag?

If you want to load images in the background, you need to create a new image element and attach a source attribute.

David