jQuery Tutorial
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.
<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:
event.screenX - returns the X coordinates relative to the screen.
event.screenY - returns the Y coordinates relative to the screen.
« Previous Next »jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page