mark smith mark smith - 2 months ago 9
jQuery Question

jquery moving from postion X to position Y slowly - animation?

i have a simple jquery animtion using fadein and it works but once faded in ... i wish to MOVE using TOP property 30 pixels upwards.. but slowly..

this is what i have so far.

$('#Friends').fadeIn("slow");


Any ideas?

I have both jquery and jquery UI loaded...

Answer

Use jquery animate and give it a long duration say 2000

$("#Friends").animate({ 
        top: "-=30px",
      }, duration );

The -= means that the animation will be relative to the current top position.

Note that the Friends element must have position set to relative in the css:

#Friends{position:relative;}