0

I'm looking for a JQuery method or plugin to load multiple images from an array.

Assume all the image paths are in a Javascript array,

  1. how can I trigger a loading event. (Gif image can be used)
  2. Load all images
  3. Alert user all images have been loaded and remove loading event.

I am aware of .Load (http://api.jquery.com/load/) I just cant see how I can make a practical example with multiple images.

LiamB
  • 18,243
  • 19
  • 75
  • 116
  • 3
    you can use jquery preload. have a look at this link http://stackoverflow.com/questions/476679/preloading-images-with-jquery – Anand Oct 03 '11 at 17:22

1 Answers1

1

this isn't perfect but I think you will get the idea

var imgCount = numberOfImages;

    $.each(yourArray,function(index, value){
           var currentImg = index;
           $('.yourImgClasses').eq(imgCount).attr('src', value).load(function() {
            if(currentImg == imgCount-1){
                 alert('Image Loaded'); 
            }
        });  
    });
Evan
  • 5,975
  • 8
  • 34
  • 63