I'm used to working with jQuery. In my current project however I use zepto.js. Zepto doesn't provide a position()
method like jQuery does. Zepto only comes with offset()
.
Any idea how I can retrieve the offset of a container relative to a parent with pure js or with Zepto?
Example
So, if we had a child element with an id of "child-element" and we wanted to get it's left/top position relative to a parent element, say a div that had a class of "item-parent", we'd use this code.
Plugin Finally, for the actual plugin (with a few notes expalaining what's going on):