Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<style>
div {border:1px solid red; height:300px;}
span {font-size:30px;}
</style>
<body>
<h1>Mouse Events</h1>
<h2>The offsetY Property</h2>
<p>The offsetY property returns the y-coordinate the mouse cursor, relative to the target element.</p>
<p>In this example, the red DIV is the target element.</p>
<p>Click inside the red DIV element:</p>
<div onclick="myFunction(event)" style="border:2px solid red;height:100px"></div>
<p id="demo"></p>
<script>
function myFunction(event) {
  let y = event.offsetY;
  document.getElementById("demo").innerHTML = "The y-coordinate is: " + y;
}
</script>
</body>
</html>