2013-10-14 56 views

回答

0

看看这个问题,但请注意,如果您的打字机效果不允许您指定回调函数(大多数不会),则第一种解决方案将不适用于您。

How to get jQuery to wait until an effect is finished?

相反,我建议使用jQuery 1.6承诺()方法中的第二溶液。因此,您的代码可能如下所示:

$(selector).teletype('slow'); 
$(selector).promise().done(function(){ 
    // will be called when all the animations on the queue finish 
    window.location.href = "page"; 
}); 

确保您使用的是jQuery 1.6或更高版本。请注意,这要求您的打字机效果被jQuery视为效果。