大佬教程收集整理的这篇文章主要介绍了Jquery效果在运行之前等待之前完成,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
谢谢
原始代码:
$('.login_menu_arrow.top').click(function(event) { $("#login_menu").slideUp(); $('.login_menu_arrow.top').hide(); $('.login_menu_arrow.bottom').show(); event.stopPropagation(); });
我的测试不起作用:
资料来源:A way to chain a sequence of events in JQuery?
1:
$('.login_menu_arrow.top').click(function(event) { $("#login_menu").slideUp(function() { $('.login_menu_arrow.top').hide(function() { $('.login_menu_arrow.bottom').show(); }); }); });
资料来源:How do you get JQuery to wait until an effect is finished?
2:
$('.login_menu_arrow.top').click(function(event) { $(this).queue(function() { $("#login_menu").slideUp(); $(this).dequeue(); }).queue(function() { $('.login_menu_arrow.top').hide(); $(this).dequeue(); }).queue(function() { $('.login_menu_arrow.bottom').show(); $(this).dequeue(); }); });
hide
不是动画效果
unless you call it with a duration,所以你不用它回调:
$('.login_menu_arrow.top').click(function(event) { $("#login_menu").slideUp(function() { $('.login_menu_arrow.top').hide(); $('.login_menu_arrow.bottom').show(); }); });
请注意,这是有效的,因为您正在为单个元素(#login_menu)设置动画.如果您要为多个元素设置动画,则会多次调用回调(每个元素在完成时调用一次).如果你动画了多个元素,并且在完成所有操作后想要一个回调,你就可以在开始动画之后使用promise,as shown in this example.但是你不需要这样做,因为你是动画单个元素.
以上是大佬教程为你收集整理的Jquery效果在运行之前等待之前完成全部内容,希望文章能够帮你解决Jquery效果在运行之前等待之前完成所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。