开发者

jQuery Smooth Sliding DIV Height

I have a Div that is 400px in height with the ID "content", I then do a slideToggle on the Div, load some data into the Div of a varying height e.g. 200px, and then do another slideToggle. What I get is the slide expanding to 400px, then jump back to 200px. And the same in reverse, expanding to 200px, then jump to 400px.

This is my code:

$('#content').slideToggle(600, function() {
    $("#content").load('data.php').slideToggle开发者_如何转开发(600);
});

So I thought I could do something like this, which would slide up the content Div, load the data, and then after it's loaded slide back down. This doesn't jump like the above method, but it is quite jerky for some reason.

$('#content').slideUp(600, function() {
    $("#content").load('data.php', function() {
        $("#content").slideDown(600);
    });
});

Can anybody tell me if there is a better way of doing this so that I can slide it smoothly?


I had a similar problem. I was able to correct this issue by setting the div height before sliding up.

Example:

$("#myDiv").height($("#myDiv").height());
$("#myDiv").slideUp();


$('#content').slideUp(600, function() {
    $("#content").load('data.php', function() {
        $("#content").slideDown(600);
    });
});

This produces the best results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜