我正在尝试在三个div之间实现渐变旋转,当前代码如下:
$(window).load(function(){
var div1 = $("#apDiv1");
var div2 = $("#apDiv2");
function fade() {
div1.stop(true, true).fadeIn(2000);
div2.stop(true, true).fadeOut(2000, function() {
// swap in/out
var temp = div1;
div1 = div2;
div2 = temp;
// start over again
setTimeout(fade, 1000);
});
}
// start the process
fade(); })
这在使用两个 div 时非常好用,但是是否可能将第三个 div 插入旋转中呢?
我尝试了这样做:
$(window).load(function(){
var div1 = $("#apDiv1");
var div2 = $("#apDiv2");
var div3 = $("#apDiv3");
function fade() {
div1.stop(true, true).fadeIn(2000);
div2.stop(true, true).fadeOut(2000);
div3.stop(true, true).fadeIn(2000);
div1.stop(true, true).fadeOut(2000, function() {
// swap in/out
var
temp = div1
div1 = div2;
div2 = div3;
div3 = div1;
div1 = temp
// start over again
setTimeout(fade, 1000);
});
}
// start the process
fade(); })
但这只是跳过了它/根本不起作用。
div1
,因此当它被重新分配为3时,它回到了第二个! =] 将div1
保存为临时变量以便在末尾再次使用。 - MackieeE