2011-12-11 54 views
0

基本上,我使用$.get()函数从网站检索数据。收到数据时,应该滑动现有内容并下滑新内容。jQuery slideDown()和slideUp()效果问题

这里是我的代码:

$.get(url, so, function (data) { 
    if (data.length>0) 
    { 
     $("#center_content_box").slideToggle(2000).empty().html(data).slideToggle(2000); 
    } 
}); 

的问题是,如果显示了新的内容,则效果会发生。当点击链接时,我想要一个类似于http://www.elegantthemes.com/preview/BusinessCard/的效果。内容上拉消失并滑动,然后再次消失。

回答

1

您可以使用动画完成处理程序将数据设置为div。

$.get(url, so, function (data) { 
      if (data.length>0) 
       { 
       $("#center_content_box").slideToggle(2000,function(){ 
        $("#center_content_box").empty().html(data).slideToggle(2000); 
       }); 
} 
}); 

请访问Example

3

您可以使用动画完成处理程序来测试动画完成

$("#item").slideDown('slow', function(){ 
            $("#item").html("Set content here after effect is done"); 
          }); 

晒的时候。

+0

香港专业教育学院做到了这一点和幻灯片效果似乎work.im上,如图该链接如何获得淡入淡出效果困惑。 $(“#center_content_box”)。slideUp(2000,function(){$(“#center_content_box”)。empty()。html(data).slideDown(2000)}); –

+1

检查答案:http://stackoverflow.com/questions/734554/jquery-fadeout-then-slideup –