-2
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 ?

trrrrrrm
  • 11,362
  • 25
  • 85
  • 130

1 Answers1

2

There is a lot of suspicious code here:

  • ImgsCount 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 Hellsing
  • 106,495
  • 44
  • 176
  • 212