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.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
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
Call
What it does
event.pageX
Learn jQuery event.pageX: horizontal mouse position relative to the document left edge, official mousemove demo with pageY, pageX vs clientX, click coordinates, examples, pitfalls, and FAQs.
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Choose a mouse event (mousemove, click, mousedown, …).
Step 2
Bind with .on("mousemove", handler) (or click / mousedown).
Step 3
Inside the handler, read event.pageX — pixels from the document’s left edge.
Return Value
Return Value
Description
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Official Demo: Log pageX / pageY
On mousemove, show both document coordinates (official idea).
Scroll. When scrollX > 0, pageX is larger than clientX.
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.