我有这个代码:
setTimeout(function() {
$('#squareone').animate({top: '-760px'},1000);
}, 22200
);
这会为#squareone
div 设置动画。我想解决的问题是动画完成后重定向。我该怎么做?我知道重定向是这样工作的window.location.href = "/home.html"
谢谢!
使用动画回调函数:
$('#squareone').animate({
top: '-760px'
}, 1000, function () {
window.location.href = "myuri"
});
您可以使用animate的完整回调来放置重定向逻辑。
$('#squareone')
.animate({top: '-760px'},
1000,
function(){
//redirect here
window.location.href=myredirectionuri;
});