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>MouseEvent offsetY Property</h1>
<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)"></div>
<p>The y-coordinate, relative to the top edge of the DIV element is: <span id="demo"></span></p>
<script>
function myFunction(event) {
  var y = event.offsetY;
  document.getElementById("demo").innerHTML = y;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_event_mouse_offsety by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 18:16:43 GMT -->
</html>