How to get the screen coordiantes using jQuery ?

Getting screen coordinates in jQuery


event.screenX and even.screenY are used to get the relative screen coordinates of the mouse pointer when mouse is clicked on the web page element.

Example jQuery code to get screen coordinates

      <title>The jQuery Example</title>

      <script src=""></script>		
      <script type = "text/javascript">
        function get_coordinates() {
          var x = event.screenX;
          var y = event.screenY;
          alert("X coordinates: " + x+ ", Y coordinates: "+y);

   <body onmousedown="get_coordinates()">
   <p>Test Section</p>
<p>Please click any where in the page to get the coordinates X and Y.</p>
screen cordinates output

event.screenX - returns the X coordinates relative to the screen.

event.screenY - returns the Y coordinates relative to the screen.

Privacy Policy  |  Copyrightcopyright symbol2020 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter