How to get the screen coordiantes using jQuery ?

Getting screen coordinates in jQuery

event.screenX
event.screenY

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

<html>
   <head>
      <title>The jQuery Example</title>

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>		
      <script type = "text/javascript">
        function get_coordinates() {
          var x = event.screenX;
          var y = event.screenY;
          alert("X coordinates: " + x+ ", Y coordinates: "+y);
        }	

      </script>		
   </head>	
   <body onmousedown="get_coordinates()">
   <p>Test Section</p>
<p>Please click any where in the page to get the coordinates X and Y.</p>
   </body>
</html>
Output:
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
^