how to get the y position of a element in javascript 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
};
}