jQuery event.pageX Property

Introduction

Return the position of the mouse pointer:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>//from   ww w .  j  a  v a2s . c  o m
<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.pageX property returns the position of the mouse pointer relative to the left edge of the document.

event.pageX
Parameter OptionalDescription
event Required.The event parameter comes from the event binding function



PreviousNext

Related