我如何设置1秒的timetime,以便进行以下动画,我尝试使用SetTimeout,但它没有用,继承人代码
$(document).ready(function(){
$('.caption_logo .flying-text').css({opacity:0});
$('.caption_logo .active-text').animate({opacity:1, marginLeft: "-350px"}, 500);
var intval = setInterval(changeText, 300);
function changeText(){
var $activeText = $(".caption_logo .active-text");
var $nextText = $activeText.next();
if($activeText.next().length == 0) clearInterval(intval);
$nextText.css({opacity: 0}).addClass('active-text').animate({opacity:1, marginLeft: "-350px"}, 500, function(){
$activeText.removeClass('active-text');
});
}
});
答案 0 :(得分:0)
您可以尝试使用如下的setTimeout函数:
$(document).ready(function(){
$('.caption_logo .flying-text').css({opacity:0});
$('.caption_logo .active-text').animate({opacity:1, marginLeft: "-350px"}, 500);
setTimeout(changeText, 300);
function changeText(){
var $activeText = $(".caption_logo .active-text");
var $nextText = $activeText.next();
if($activeText.next().length > 0) setTimeout(changeText, 300);
$nextText.css({opacity: 0}).addClass('active-text').animate(
{
opacity:1,
marginLeft: "-350px"
},
500,
function(){
$activeText.removeClass('active-text');
}
);
}
});
希望它适合你。