What is the role of clientX Mouse Event in JavaScript?

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


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

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