[英]How to execute two functions synchronously : jQuery show & animate
如何同步(同时)执行两个功能? 是否可以在.show函数中运行.animate函数?
<script>
jQuery(document).ready(function(){
jQuery('#tricksImg').click(function() {
jQuery('#appear').show(function() {
jQuery('html, body').animate({
scrollTop: jQuery("#appear").offset().top
});
});
});
});
</script>
这些函数应该已经尽可能快地执行,因此在这种情况下,对animate
的回调是无用的。
jQuery('#tricksImg').click(function() {
jQuery('#appear').show();
jQuery('html, body').animate({
scrollTop: jQuery("#appear").offset().top
});
});
是的,我的意思是异步的。 在平行下。 我可以解决这个问题,谢谢,这种逻辑也更有意义。
jQuery('#tricksImg').click(function() {
jQuery('#appear').show(function() {
jQuery('html, body').animate({
scrollTop: jQuery("#appear").offset().top
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.