Couldn't assign 'top' from variable in jQuery Animate
- by bhu1st
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.