I’m certain I’ve seen this before. This is how i remember it
$cnta.css({ top:'+=50' });
Needless to say, it doesn’t work 🙂
I know i can parse the css value, manipulate the result and put it back into css, but that takes twice the code.
Thanks for answers!
That works for
.animate():For
.css(), you can pass a function that will do the addition for you:$cnta.css(‘top’, function(i,current) { return parseInt(current) + 50; });EDIT: Changed the animation from
1to0. As @Nick Craver noted, a0animation will work.EDIT: Gave a better answer for the
.css()version. If thetophas not been given any value yet, then doing.parseInt(current)will returnNaN. Updated to correct it.