开发者

Get actual div height during jQuery animate

I have some animated graphs. It's cool开发者_JAVA百科. But I need to write out the current height of the div to another div during the animation (like an analogue timer). I have the starting and the final height, too. So, maybe a tricky method is OK, where a continuous write out is happening while the animation itself, separately. Unfortunately, I have no idea to do this neither. Thanks!


Use the under-documented animate step function (demo):

$('#div1').animate({
    height: 500
}, {
    step: function(height) {
        $('#div2')
            .height(height)
            .html( parseInt(height,10) );
    },
    duration: 500,
    complete: function() {}
});


Try this using jquery

$("#div2").text($("#div1").height());

you'll have to append it to your animations code, but as you didn't post it I can't guess it!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜