What is the role of clientY Mouse Event in JavaScript?


When a mouse event is triggered, the clientY mouse event property is used to get the vertical coordinate of the mouse pointer. This is according to the current window.

Example

You can try to run the following code to learn how to implement clientY Mouse event in JavaScript.

<!DOCTYPE html>
<html>
   <body>
      <p onclick = "coordsFunc(event)">Click here to get the x (horizontal) and y (vertical) coordinates (according to current window) of the mouse pointer.</p>
     
      <script>
         function coordsFunc(event) {
            var x_coord = event.clientX;
            var y_coord = event.clientY;
            var xycoords = "X coords= " + x_coord + ", Y coords = " + y_coord;
            document.write(xycoords);
         }
      </script>
   </body>
</html>

Updated on: 23-May-2020

94 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements