jQuery event.pageY property


The event.pageY property in jQuery is used to return the position of the mouse pointer, relative to the top edge of the document.

Syntax

The syntax is as follows −

event.pageY

Example

Let us now see an example to implement the jQuery event.pageY property −

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $(document).mousemove(function(event){
         $("span").text("X: " + event.pageX + ", Y: " + event.pageY);
      });
   });
</script>
</head>
<body>
<h2>Mouse Pointer Position</h2>
<p>Mouse pointer position coordinates = <span></span></p>
<p>Place mouse cursor anywhere on the document</p>
</body>
</html>

Output

This will produce the following output. Before placing mouse cursor on the document −

After placing mouse cursor anywhere on the document −

Updated on: 12-Nov-2019

79 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements