jquery - 如何在动画结束后才执行 Action ?

标签 jquery

我有我的代码:

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

我希望在按键时禁用输入,并且只有在执行动画时才启用输入。

我怎样才能做到这一点?

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

最佳答案

使用回调:

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

关于jquery - 如何在动画结束后才执行 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6614313/

相关文章:

Jquery 选择子级但不选择父级

jQuery SlideToggle,显示/隐藏速度

c# - Jquery 无法在 ASP.NET UpdatePanel 中工作

javascript - 单击时更改 SVG 填充覆盖 - jQuery

jquery - 奇特盒子2 : formatting title

jquery - IE中请求Content-Length等于0

jquery - 使用动态内容调整 fancybox 的大小

c# - 从 javascript 文件调用 View javascript 函数

jquery - 创建并推送到多维数组

php - 如何制作 jAlert() 像 'Please Wait' 消息。(没有 OK 按钮)