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

问题描述

我有三个div:A,B和C.A当前可见,我希望B替换它.我可以通过以下方法轻松地做到这一点:

I have three divs: A, B and C. A is currently visible and I wish for B to replace it. I could easily do this with the following:

$('#A').hide();
$('#B').show();

但是,这将导致更改非常突然.但是,如果我将"hide"替换为"fadeOut",将"show"替换为"fadeIn",则A仍在淡出,而B仍在淡入,这看起来很令人困惑.我该如何让B等待A淡出,然后才开始淡入?

However, that will cause the change to be quite abrupt. If I however I swap "hide" for "fadeOut" and "show" for "fadeIn" then A is still fading out while B is still fading in and it looks pretty confusing. How can I make B wait for A to be faded out before it starts to fade in?

先谢谢您了:)

推荐答案

fadeOut可以采用在第一个效果完成后运行的回调函数:

fadeOut can take a callback function that runs after the first effect is completed:

$('#A').fadeOut(function () {
    $('#B').fadeIn();
});

应该这样做.

这篇关于jQuery淡入淡出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-24 15:09