get x and y position of element in javascript using e code example
Example: how to get x y position of an element
function getOffset(el) {
const rect = el.getBoundingClientRect();
return {
left: rect.left + window.scrollX,
top: rect.top + window.scrollY
};
}