Open In App
Related Articles

HTML | DOM MouseEvent clientX Property

Improve Article
Save Article
Like Article

The MouseEvent clientX property is a read-only property which is used to return the horizontal coordinate of the mouse pointer based on the current window when a mouse event was triggered.



Return Value: It returns a number which represents the vertical coordinate of the mouse pointer in pixels.

Below program illustrates the MouseEvent clientX property :

Finding out the horizontal coordinates of the mouse pointer when the mouse button is clicked on an element.

<!DOCTYPE html>
    <title>MouseEvent clientX Property</title>
        h1 {
            color: green;
        h2 {
            font-family: Impact;
        body {
            text-align: center;
    <h2>MouseEvent clientX Property</h2>
    <p onclick="coord(event)">To get the x of the mouse pointer,
      click on this paragraph. </p>
    <p id="gfg"></p>
        function coord(event) {
            var getXCoord = event.clientX;
            var result = "X coordinate: " + getXCoord;
            document.getElementById("gfg").innerHTML = result;


After clicking on the paragraph:

Supported Web Browsers:

  • Opera
  • Internet Explorer
  • Google Chrome
  • Firefox
  • Apple Safari

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 30 Jan, 2019
Like Article
Save Article
Similar Reads
Complete Tutorials