Edit This Code:
<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="position:absolute;top:75px;">This is a div.</div>

<button type="button" onclick="myFunction()">Return top position of div</button>

<script>
function myFunction() {
    alert(document.getElementById("myDiv").style.top);
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy