1
我是一个初学者,我想知道如何创建一个类型效果(像这些 - https://stackoverflow.com/questions/4074399/what-to-choose-for-typewriter-effect-in-javascript),并让它在完成时转到另一个页面(window.location.href =“page” )...我不知道如何连接两者?jquery类型效果后切换页面
我是一个初学者,我想知道如何创建一个类型效果(像这些 - https://stackoverflow.com/questions/4074399/what-to-choose-for-typewriter-effect-in-javascript),并让它在完成时转到另一个页面(window.location.href =“page” )...我不知道如何连接两者?jquery类型效果后切换页面
看看这个问题,但请注意,如果您的打字机效果不允许您指定回调函数(大多数不会),则第一种解决方案将不适用于您。
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视为效果。