I have a problem with jquery and position().
I want to move a text element <div id="text"> to sit onto another element on an event.
The other element looks like this:
<div id=pic><img src=pic.jpg></div>
The jquery i’m using to position it is this:
var pos = $('#pic').offset();
$('#text').animate({ top: pos.top, left: pos.left }, 0);
Now for some reason the #text is getting displayed way further over to the right and below the actual img div.
Any idea what’s causing this?
Does
#texthaveposition: absoluteset? Animating thetopandleftproperties won’t have the expected effect otherwise..offsetreturns thetopandleftrelative to the document, but.animatemodifies thetopandleftstyle properties, which are dependent upon thepositionproperty.