Get the offset position of an element relative to its parent
Get the top/left coordinates of an element relative to the offset parent.
Use offsetLeft
and offsetTop
for finding an element's position in px with respect to its offsetParent
container:
var el = document.querySelector('div');
console.log(el.offsetLeft, el.offsetTop);