淡出与内容A股利和淡入同一分区与内容B [英] Fade out a div with content A, and Fade In the same div with content B

查看:101
本文介绍了淡出与内容A股利和淡入同一分区与内容B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下几点:

$(function() {
    $('.ajaxloader').click(function(event) {
        var target = $(this).attr('href');
        window.location.hash = target;
        $('#conteudoInscricao').fadeOut('slow', function() {
            $.ajax({
                url: target,
                    success: function(data) {
                        $('#conteudoInscricao').html(data);
                        $('#conteudoInscricao').fadeIn('slow');
                    }
            });
        });
        return false;
    });
});

本作品几乎确定。事情是...的效果并不顺利。我的意思是,首先它淡出内容A,那么它保持空白,然后就消失在内容上B.

This works almost ok. The thing is... the effect is not smooth. I mean, first it fades out the content A, then it stays blank, and then it fades IN content B.

我想是缓解影响,所以,虽然他淡出真的接近尾声,他开始淡出,这样的效果可能是平滑的。

What I would like is to ease the effect so that, while he is fading out really near the end, he starts to fade in so that the effect could be smooth.

这怎么可能实现对于低于code?

How can that be achieve regarding the code below?

感谢很多提前, MEM

Thanks a lot in advance, MEM

推荐答案

试试这个:

$(function() {
    $('.ajaxloader').click(function(event) {
        var target = $(this).attr('href');
        window.location.hash = target;
        $.ajax({
            url: target,
            success: function(data) {
                $('#conteudoInscricao')
                    .fadeOut('slow', function() {
                        $(this).html(data).fadeIn('slow');
                    });
            }
        });
        return false;
    });
});

所以,你已经检索到的数据后,避免了任何时间上的差距,以等待数据反应的影响才会发生。

So the effect will happen only after you have retrieved your data, avoiding any time gap to wait the data response.

这篇关于淡出与内容A股利和淡入同一分区与内容B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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