What is the role of clientY Mouse Event in JavaScript?

HTMLJavascriptProgramming Scripts

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>
raja
Published on 26-Feb-2018 11:52:17
Advertisements