1

我有这个代码:

setTimeout(function() {  
  $('#squareone').animate({top: '-760px'},1000);
 }, 22200

 ); 

这会为#squareonediv 设置动画。我想解决的问题是动画完成后重定向。我该怎么做?我知道重定向是这样工作的window.location.href = "/home.html"

谢谢!

4

2 回答 2

2

使用动画回调函数:

$('#squareone').animate({
    top: '-760px'
}, 1000, function () {
    window.location.href = "myuri"
});
于 2013-06-09T16:58:32.433 回答
1

您可以使用animate的完整回调来放置重定向逻辑。

$('#squareone')
         .animate({top: '-760px'}, 
           1000, 
           function(){
               //redirect here
              window.location.href=myredirectionuri;
   });
于 2013-06-09T16:58:41.580 回答