哈哈:)我的codepen 的代码笔记是:http://codepen.io/shinewaker/pen/eBwPxJ

-------------------------------------------------------

I mean, check it out this code :

<a href="#" id="link">Link</a>
<span>Moving</span> $('#link').click(function () {
console.log("Enter");
$('#link').animate({ width: 200 }, 2000, function() {
console.log("finished");
});
console.log("Exit");
});

as you can see in console, the "animate" function is Asynchronous, and it "fork" the flow of the event handler block code. In fact :

$('#link').click(function () {
console.log("Enter");
asyncFunct();
console.log("Exit");
}); function asyncFunct() {
console.log("finished");
}

follow the flow of the block code!

If I wish to create my function asyncFunct() { } with this behaviour, how can I do it with javascript/jquery? I think there is a strategy without use setTimeout() ​

You cannot make a truly custom asynchronous function. You'll eventually have to leverage on a technology provided natively, such as:

  • setInterval
  • setTimeout
  • requestAnimationFrame
  • XMLHttpRequest
  • WebSocket
  • Worker
  • Some HTML5 APIs such as the File API, Web Database API
  • Technologies that support onload
  • ... many others

In fact, for the animation jQuery uses setInterval.

最新文章

  1. YII rules常见规则
  2. easyui 下拉树改造
  3. min-height
  4. JavaScript text highlighting JQuery plugin
  5. How to install ZeroMQ on Ubuntu14.04
  6. markdown下编辑latex数学公式
  7. 欧拉工程第51题:Prime digit replacements
  8. 基于python3的手机号生成脚本
  9. 记录遇到的IE8兼容性问题汇总
  10. Metasploit渗透测试魔鬼训练营
  11. JavaScript高级程序设计12.pdf
  12. 《EM-PLANT仿真技术教程》读书笔记(持续更新中)
  13. 关于Android L软件安装问题的发现
  14. onethink插件二(首页图片轮播)
  15. mac下安装 resin 奇葩问题总结
  16. 一种基于http协议的敏感数据传输方案
  17. 怎么修改PDF文档图片内容
  18. SHELL脚本--数学运算和bc命令
  19. 二、xadmin----简单使用
  20. LeetCode 589 N-ary Tree Preorder Traversal 解题报告

热门文章

  1. mouseover和this的巧用
  2. Python学习笔记——基础篇【第五周】——算法(4*4的2维数组和冒泡排序)、时间复杂度
  3. Java 并发 线程的优先级
  4. [河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)
  5. HDU 1040 As Easy As A+B(排序)
  6. epoll完整例子
  7. chrome下li标签onclick事件无效
  8. 简单的socket方法
  9. python 基础学习1
  10. pythonRedis 订阅功能实现