jquery: fade in image after image

前端 未结 3 2057
青春惊慌失措
青春惊慌失措 2020-12-30 15:28

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 display

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 16:19

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

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

提交回复
热议问题