jQuery & jQuery UI Documentation

jQuery & jQuery UI

event.pageX

event.pageX Returns: Number

Description: The mouse position relative to the left edge of the document.

  • version added: 1.0.4event.pageX

Example:

Show the mouse position relative to the left and top edges of the document (within the iframe).

<!DOCTYPE html>
<html>
<head>
  <style>body {background-color: #eef; }
div { padding: 20px; }</style>
  <script src="http://code.jquery.com/jquery-1.7rc2.js"></script>
</head>
<body>
  <div id="log"></div>
<script>$(document).bind('mousemove',function(e){ 
            $("#log").text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY); 
}); </script>

</body>
</html>