Couldn't assign 'top' from variable in jQuery Animate

Posted by bhu1st on Stack Overflow See other posts from Stack Overflow or by bhu1st
Published on 2010-06-04T06:02:51Z Indexed on 2010/06/04 6:09 UTC
Read the original article Hit count: 190

Filed under:
|

Hi,

I am stuck here, i am trying to animate number of 'x' divs (the code below is just for one div) by selecting their original 'top' position & adding some 'newTop' pixel values to them.

        var dur = 1500;
        var origTop = $("#div_x").position().top;
        var newTop = parseInt(origTop) + 30;
        $("#div_x").animate({
            top : newTop + "px"
        },
        dur);

I checked alerting the 'newTop' variable and it's showing correct values but the animation is not working. I tried different variants to assign 'top' to the animate function but nothing is working.

any suggestion would help me a lot. thanks in advance.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-animation