jQuery event.pageX Property

Last Updated:

jQuery event.pageX Property

The jQuery event.pageX property returns the mouse position relative to the left edge of the document.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery pageX Property</h1> <div>Move your cursor over me.</div> <p>pageX is <strong>0</strong></p> <script> $(document).ready(function(){ $("div").mousemove(function(e){ $("strong").text(e.pageX); }); }); </script> </body> </html>

Syntax

event.pageX;

Return Value

Value Explanation
Number Returns the position of the mouse pointer, relative to the left edge of the document.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
event.pageXYesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author