jQuery等待事件完成 [英] jQuery wait for event to complete

查看:130
本文介绍了jQuery等待事件完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一个功能时,我怎么能意识到

How can I realize that when I have a function

$('.anyclass').slideToggle(1000);

程序在完成slideToggle之后将函数test()放入?

that the program exetutes the function test() after the slideToggle completed?

如果我这样写:

$('.anyclass').slideToggle(1000);
test();

... test()在slideToggle完成之前执行。

...test() gets executed before slideToggle completed.

我怎么知道?我不太了解jQuery ...

How can I realize? I don't know jQuery very well ...

感谢您的帮助!此致,Florian

Thank you for your help! Regards, Florian

编辑:结果你可以在这里看到: www .virtual-swiss-hornets.ch

Results u can see here: www.virtual-swiss-hornets.ch

推荐答案

你可以添加回调函数到你的jQuery函数。

You can add a callback function to your jQuery function.

$('.anyclass').slideToggle(1000,function() { test(); });

幻灯片完成后,该功能才会激活。

That function will ONLY fire once the slide is complete.

这篇关于jQuery等待事件完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆