element.offsetLeft
and element.offsetTop
are the pure javascript properties for finding an element's position with respect to its offsetParent
; being the nearest parent element with a position of relative
or absolute
Alternatively, you can always use Zepto to get the position of an element AND its parent, and simply subtract the two:
var childPos = obj.offset();
var parentPos = obj.parent().offset();
var childOffset = {
top: childPos.top - parentPos.top,
left: childPos.left - parentPos.left
}
This has the benefit of giving you the offset of a child relative to its parent even if the parent isn't positioned.