Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqueryfadein和out_Jquery_Timing_Fadein_Fadeout - Fatal编程技术网

jqueryfadein和out

jqueryfadein和out,jquery,timing,fadein,fadeout,Jquery,Timing,Fadein,Fadeout,看看这个: 淡入淡出效果有点混乱,我不知道如何使它正常工作 我希望代码按以下顺序运行: 淡出块 插入新内容 渐入块 该页面的jQuery代码: $(“#导航a”)。单击(函数(){ $.get(“page.php”,{page:$(this.attr('id')},函数(数据){ $('#content').fadeOut('slow').html(data).fadeIn('slow'); }); }); 您的问题就在这里:$('#content').fadeOut('slow').html(

看看这个:

淡入淡出效果有点混乱,我不知道如何使它正常工作

我希望代码按以下顺序运行:

  • 淡出块
  • 插入新内容
  • 渐入块
  • 该页面的jQuery代码:

    $(“#导航a”)。单击(函数(){ $.get(“page.php”,{page:$(this.attr('id')},函数(数据){ $('#content').fadeOut('slow').html(data).fadeIn('slow'); });
    });

    您的问题就在这里:
    $('#content').fadeOut('slow').html(data.fadeIn('slow');})
    这将在
    淡出
    完成之前启动
    fadeIn
    。您要执行以下操作:

    $('#content').fadeOut('slow', function(){
      $(this).html(data).fadeIn('slow')
    });
    

    fadeOut
    的第二个参数是在
    fadeOut
    完成后调用的函数

    您可以在ajax调用之前将淡出移动到:

    $('#navigation a').click(function(){ $('#content').fadeOut('slow'); $.get("page.php", { page: $(this).attr('id') },
        function(data){ $('#content').html(data).fadeIn('slow'); }); });