如何在动画完成后才执行操作? [英] How to perfom action only after animate is finished?

查看:56
本文介绍了如何在动画完成后才执行操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的代码:

$(this).attr("disabled","disabled");
$(this).animate({'opacity':'0.6'}, 200);
$(this).animate({'opacity':'1'}, 200);
$(this).attr("disabled","");

我想在 keypress 'ed,只有当动画执行时才会启用。

I want that the input would be disabled when the keypress'ed and it would be enabled only then, when the animation would be executed.

我该怎么做?

编辑:我刚才意识到我可以这样做: $(this).delay(200).attr(disabled,); 。这是好的做法吗?

I just realized I could do like that: $(this).delay(200).attr("disabled","");. Is it good practice?

推荐答案

使用回调:

$(this).animate({'opacity':'0.6'}, 200, function() {
    // Animation complete.
  });

这篇关于如何在动画完成后才执行操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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