本文介绍了jQuery:逐张图片渐入渐出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有10张图片,下载完图片后,我希望它们一次又一次地淡入淡出.如何检测图像已加载并准备显示?我是否应该循环浏览已加载的图像fadeIn,并在褪色一次后等待下一个图像加载?

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?

推荐答案

只需在图像上使用load()事件.例如

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

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

这篇关于jQuery:逐张图片渐入渐出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 21:51