jQuery队列事件 [英] jQuery queue events

查看:74
本文介绍了jQuery队列事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想要做的是使用jQuery为我正在使用的一些AJAX调用协调一些效果。我的问题是第二个div的fadeIn与第一个div的fadeOut同时触发。

So what I want to do is to coordinate some effects using jQuery for some AJAX calls that I'm working with. My problem is that the fadeIn for the second div fires at the same time with the fadeOut for the first div.

这也适用于其他事件所以我是好奇,有没有办法在fadeOut完成后才能启动fadeId?

This could apply to other events as well so I'm curious, is there any way to make fadeId launch ONLY after fadeOut is done ?

jQuery("#div1").fadeOut("slow"); 
jQuery("#div2").fadeIn("slow");

谢谢

推荐答案

您可以使用回调来完成此操作。查看jQuery docs

You can do this by using a callback. Check out the jQuery docs.

jQuery("#div1").fadeOut("slow", function() { jQuery(this).fadeIn('slow'); }); 

几乎所有的jQuery效果都会在效果结束后执行回调。

Pretty much all of the jQuery effects take a callback to execute after the effect is over.

这篇关于jQuery队列事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆