event.pageX is a Number on the jQuery event object. It is the mouse pointer’s horizontal position in pixels relative to the left edge of the document (scroll included). Added in jQuery 1.0.4. Pair it with event.pageY for a full document (x, y) point.
Remember
event.pageX // Number — px from document left (read-only)
$(document).on("mousemove", function (event) {
// pageX: horizontal · pageY: vertical
console.log(event.pageX, event.pageY);
});
pageX → document coordinates (includes scroll)
clientX → viewport coordinates (visible window)
offsetX → relative to the event target element
Bind a mouse event, then read pageX (and usually pageY) inside the handler.
Choose a mouse event (mousemove, click, mousedown, …).
Bind with .on("mousemove", handler) (or click / mousedown).
Inside the handler, read event.pageX — pixels from the document’s left edge.
For a full point, also read event.pageY.
Use document coords for pins, drag, and scroll-aware UI — not viewport-only math.
Piece
Required?
Role
Mouse event
Yes
Provides pointer coordinates
event.pageX
—
Horizontal px from document left
event.pageY
Optional
Vertical px from document top
Handler
Yes
Reads and uses the values
Pseudocode
Pseudocode
element.on("mousemove" | "click" | …, handler)
when mouse event fires:
event.pageX = distance from document left (px)
event.pageY = distance from document top (px)
// includes scroll — not just the visible viewport
call handler(event)
// Rough relation:
// pageX ≈ clientX + window.scrollX
Reference
Cheat Sheet
Keep these facts handy while reading pointer coordinates.
Topic
Detail
Type
Number property (not a method)
Since
jQuery 1.0.4
Origin
Document left edge
Unit
CSS pixels
Official demo
mousemove → log pageX + pageY
vs clientX
Document (+ scroll) vs viewport
vs offsetX
Document vs target element
Mutates?
No — read-only
Try it
Live Preview
Move the pointer over the pad to see pageX and pageY — same idea as the official jQuery API demo.
Bound with .on("mousemove") — move over the pad to update coordinates.
Result
Move your mouse over the pad…
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official Demo: Log pageX / pageY
On mousemove, show both document coordinates (official idea).
Inside area — pageX: 256, pageY: 172
— or —
Left the area.
How It Works
Scope. Bind on #area so only moves inside that element count.
Both axes. Log pageX and pageY as one document point.
Leave.mouseleave clears or resets the readout.
Pattern. Useful for charts, maps, and hover HUDs.
Edge Cases & Pitfalls
Watch for these when using pageX in real UI.
scroll
Do not mix pageX with viewport math
Positioning an element with position: fixed needs viewport coords (clientX). Document layout / absolute pins need pageX.
events
Only mouse (pointer) events
Keyboard events do not give a meaningful pageX. Bind mousemove, click, mousedown, and related mouse events.
freq
mousemove fires very often
Keep handlers light. Heavy DOM work on every move can stutter — throttle or only update what changed.
readonly
You cannot assign event.pageX
It is read-only. Copy the value into your own variable or CSS if you need to reuse it.
Compatibility
Browser Support
event.pageX is a jQuery event-object property (since 1.0.4). The underlying mouse coordinates are standard in all modern browsers. Works wherever your loaded jQuery version runs.
✓ Stable · jQuery 1.0.4+
event.pageX
Supported wherever jQuery 1.0.4+ is loaded. Prefer jQuery 3.x with .on("mousemove") / .on("click") for modern code.
100%jQuery support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
event.pageX1.0.4+
Bottom line: Safe for production. Use pageX for document coordinates; pair with pageY; use clientX only when you need viewport space.
Analysis
Performance Notes
Approach
Cost
Best for
.on("click", …) + pageX
Cheap
One-shot click positions
.on("mousemove", …)
High frequency
Live tracking — keep work tiny
Delegated document mousemove
Fine
Global cursor HUD / tools
Heavy layout in mousemove
Can stutter
Throttle or update only changed fields
Reading pageX itself is free. The cost is how often you run the handler — especially on mousemove.
Remember
Key Takeaways
Role: horizontal mouse position from the document’s left edge.
vs clientX:pageX includes scroll; clientX is viewport-only.
Keep light:mousemove handlers should stay short.
One line:event.pageX is “how far from the document’s left edge is the pointer?”
Frequently Asked Questions
event.pageX is a Number on the jQuery event object. It is the mouse pointer’s horizontal position in pixels relative to the left edge of the document — including any horizontal scroll. Available since jQuery 1.0.4 on mouse events such as mousemove, click, and mousedown.
clientX is relative to the browser viewport (visible window). pageX includes document scroll — roughly pageX ≈ clientX + window.scrollX. Use pageX for document-wide coordinates; clientX for viewport-fixed UI.
pageX is horizontal (from the document’s left edge). pageY is vertical (from the document’s top edge). Together they form a (x, y) point in document space — the official jQuery demo logs both on mousemove.
Mouse events expose pageX — mousemove, mouseenter, mouseleave, mouseover, mouseout, mousedown, mouseup, and click. Keyboard events do not carry a meaningful pointer pageX.
No. pageX is read-only — the browser sets it from the pointer when the event fires. Read pageX and apply it to your own variables or element positions.
pageX is relative to the entire document. offsetX is relative to the event target’s padding edge. Use pageX for absolute document positioning; offsetX for clicks inside a specific box.