Get Element’s Distance from Top in JavaScript
In JavaScript, you can use the offsetTop property to get the distance of an element from the top of the page. Example:
var element = document.getElementById("myElement");
var distance = element.offsetTop;
console.log(distance);
In the above code, the method getElementById is used to retrieve the element with a specified id, then the offsetTop property is used to determine the distance between the element and the top of the page, and finally the result is printed to the console.