You want to get the position of the element:
We can use getBoundingClientRect () method;
His return value from, provides a window element to element, not the page
Understand: getBoundingClientRect used to obtain an element with respect to the collection window. There set top, right, bottom, left and other attributes.
Usage: let a = obj.getBoundingClientRect () // obj represents the elements we get
console.log (a) // a is an object that has a position on the above we get the elements who left right top bottom of the property, the above is what we get
If a page, we can use offsetTop or offsetLeft