javascript - 如何在Javascript中等待行的执行?

标签 javascript jquery

$("#div_id").click(function() {
    $(this).effect("shake", { times:3 }, 300);
    // Here I want wait that the div_id can complete its shake
    alert('hello');
  }

.delay 我尝试过,但不起作用。

最佳答案

$(this).effect("shake", { times:3 }, 300, function() {

    // this will alert once the animation has completed
    alert('hello');
});

关于javascript - 如何在Javascript中等待行的执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5790501/

相关文章:

javascript - 将单个单词对齐成行

javascript - 根据字段值呈现内部 jquery-template

javascript - 如何使用 Web RTC - Javascript 发送 UDP 数据包?

javascript - 如何将值限制在 2 个整数之间?

jquery - 如何使用 jQuery 使 DIV 弹出以响应悬停事件(如国家地理网站)?

javascript - 本地通知插件仅在index.html中工作 - 无法读取未定义的属性 'notification'

jquery - 提交后重置表单并清除缓存

javascript - Truffle JS 测试不起作用

javascript - 调用阴影原型(prototype)方法的更简单/更好的方法?

javascript - 使用多个下拉菜单切换无法按预期工作