简体   繁体   English

jQuery Chrome / Safari FadeOut

[英]Jquery Chrome/Safari FadeOut

So I'm trying to make a very simple effect where two images that are laid on top of each other using positioning crossfade when the page loads. 因此,我试图做出一种非常简单的效果,即在页面加载时,使用定位淡入淡出的方式将两个图像放置在彼此的顶部。 I have it almost working just right in FF and IE8 except it does not crossfade when you first visit the page, you must refresh for the fade to occur. 我几乎可以在FF和IE8中正常工作,除了第一次访问页面时它不会淡入淡出,您必须刷新才能使淡入淡出。

The effect is loaded here: http://www.cloudfarmstudio.com/image%20fade%20test/ 在此处加载效果: http : //www.cloudfarmstudio.com/image%20fade%20test/

Can anyone tell me what I'm doing wrong!? 谁能告诉我我在做什么错!!

Thanks! 谢谢!

The issue is in using $(document).ready . 问题在于使用$(document).ready Ready fires as soon as the DOM is loaded, this is before the images have loaded. DOM加载后即立即就绪,这是在图像加载之前。 So you're trying to fade out an image that hasn't loaded yet. 因此,您尝试淡出尚未加载的图像。 You can fix this by using $(window).load . 您可以使用$(window).load来解决此问题。

$(window).load(function(){
  $('.OldImage').fadeOut();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM