I believe that the jQuery API "position ()" is not what you are looking for, as it is defined as the "current position of the element relative to the offset parent" (basically this corresponds to element.offsetTop)
Therefore, if you want the top position of an element to relate to its parent (not necessarily the offset parent), use this instead:
var top = (element.parentNode == element.offsetParent) ? element.offsetTop : element.offsetTop - element.parentNode.offsetTop;
source share