jquery - Difference between .position() and .offset() and an interesting Observation? -
question: difference between .offset() , .position()?
i read docs on still not @ clear real difference between these two. request simple explanation on same.
my observation:
i wrote javascript code placed in web page(.aspx) itself. javascript setting position of modal popup. in code used .position() position of div placing modal popup. now, here twist- when moved javascript code seperate js file, .position() not @ working instead used .offset() , working fine.
i request explaination on ?
that depends on context element in. position returns position relative offset parent, , offset same relative document. obviously, if document offset parent, case, these identical.
if have layout this, however:
<div style="position: absolute; top: 200; left: 200;"> <div id="sub"></div> </div>
then offset sub 200:200, position 0:0.
hope makes sense.
Comments
Post a Comment