Get position/offset of element relative to a parent container?

element.offsetLeft and element.offsetTop give an element’s position with respect to its offsetParent (which is the nearest parent element with a position of relative or absolute.)

Leave a Comment