jquery: fade in image after image

monkeylee picture monkeylee · Aug 18, 2009 · Viewed 10k times · Source

I have a page with 10 images in and I want to fade them in one after another once the image has been downloaded. how can I detect the image is loaded and ready to be displayed? and should I loop through the loaded images fadeIn and once fadedIn wait for the next to load?

Answer

Kris Erickson picture Kris Erickson · Aug 18, 2009

Just use the load() event on an image. E.g.

$('#some_image').hide()
    .load(function () {
      $(this).fadeIn();
    })
    .attr('src', 'images/headshot.jpg')