[英]First fadein doesn't seem to work sometimes (jquery)
我创造了一个小动画故事。 问题是有时第一次淡入淡出不会触发。 这似乎只是有时发生,在某些情况下我似乎无法弄清楚。 据我所知,它与缓存有关。
以下是经常出现问题的页面的代码:
//waits until document is open
$(window).load(function() {
//if it's night time when you read this it displays a night time photo, if it's day time it's a day time photo... don't know how many people might notice
if (time === "night"){
$.backstretch("downtownnight.jpg");
//makes the font white with a black outline so you can read it easily on the night photo
$("#content").css("color","#FFFFFF");
$("#content").css("text-shadow","1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000");
}
else {
$.backstretch("downtownday.jpg");
$("#content").css("text-shadow","1px 0 0 #fff, 0 -1px 0 #fff, 0 1px 0 #fff, -1px 0 0 #fff"); }
});
$(document).ready(function(){
//fades in the first line of text
$("#partFive").fadeIn(2000)
setTimeout(function () {
//fades in the second line of text
$("#partFive").fadeOut(2000)
setTimeout(function () {
$("#awesome").fadeIn(3000)
setTimeout(function () {
$("#awesome").fadeOut(2000)
setTimeout(function () {
$("#awesome").fadeOut(1000)
setTimeout(function () {
$("#partSix").fadeIn(2000)
}, 2000);
}, 2000);
}, 2000);
}, 2000);
}, 2000);
});
我在堆栈溢出中发现了此问题以停止缓存问题,但似乎无济于事
<!-- ignores any cache you might have! -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
您可以在此处找到该网站的测试版本: http : //www.chilltoday.com/test/
要求使用HTML,它在pastebin中: http : //pastebin.com/XyM9si2c
如果要使用fadeIn效果,则需要在调用fadeIn()之前确保#partFive在开始时是隐藏的。
我看不到您的代码有什么问题。 但是,我添加了“ display:none;”。 对于所有div,您都需要fadeIn()似乎对我有用。
#partFive, #awesome, #partSix {
display: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.