Return the position of the mouse pointer:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from w ww .ja va 2s. c om*/ <script> $(document).ready(function(){ $(document).mousemove(function(event){ $("span").text("X: " + event.pageX + ", Y: " + event.pageY); }); }); </script> </head> <body> <p>The mouse pointer position is at: <span></span></p> </body> </html>
The event.pageY property returns the position of the mouse pointer relative to the top edge of the document.
event.pageY
Parameter | Optional | Description |
---|---|---|
event | Required. | The event parameter comes from the event binding function |