HTML 代码
<div id="foo">
<h1>foo</h1>
<p>Pellentesque habitant morbi tristique.</p>
</div>
<div id="bar">
<h1>bar</h1>
</div>
jQuery 代码
$('#bar').click(function () {
$('#foo p').hide('slow').appendTo('#bar').show('slow');
})
预期结果
单击#bar 时
- 隐藏
p元素#foo - 附加
p到#bar - 显示
p现在是#bar
实际结果
- 附加
p到#bar - 隐藏
p元素#foo - 显示
p现在是#bar
问题
- 是什么决定了 jQuery 链中方法的执行顺序?
- 如何确保每个事件在下一个事件开始之前完成?