slidedown jquery问题

时间:2010-01-18 14:44:27

标签: jquery

function show_destination(country_id,airport_id){
    $.ajax({
        type: "POST",
        url: "function.php",
        data: "country_id="+country_id+"&airport_id="+airport_id+"&action=destination",
         beforeSend: function() { $("#loader_destination").html(''); },
        success: function(msg){
            // $(".loader_destination").empty();    
            //$("#destination_div").html(msg);
            //$("#destination_div").slideDown("slow",function(){$("#destination_div").html(msg);})  
            //$("#destination_div").html(msg,function(){$("#destination_div").slideDown("slow");});
            $('#destination_div').slideDown(500, function() { $('#destination_div').html(msg);});

           }
 });

}

slideDown此效果不起作用, 输出只是显示,对显示输出没有任何影响,

3 个答案:

答案 0 :(得分:2)

在Slidingown生效之前,您才设置HTML:

$('#destination_div').slideDown(500, function() { 
  $('#destination_div').html(msg);
});

你需要切换它:

$('#destination_div').html(msg).slideDown(500);

答案 1 :(得分:1)

查看你的代码我会说这个元素在它应该滑动的500ms时是空的。 尝试:

$('#destination_div').hide().html(msg).slideDown(500);

答案 2 :(得分:0)

你想要达到什么目标?

在我看来...... ...

$('#destination_div').slideDown(500, function() { $('#destination_div').html(msg);});

...将向下滑动DIV,然后设置HTML。如果DIV为空,那么你将看不到动画。

怎么样:

var $destination_div =  $('#destination_div');
$destination_div.html(msg);
$destination_div.slideDown(500);

我在$ destination_div中缓存以提高性能,但您可以改为使用链接:

$('#destination_div').html(msg).slideDown(500);

你甚至可能想要扩充你的beforesend方法:

beforeSend: function() { 
    $("#loader_destination").html(''); 
    $('#destination_div').hide(); 
}