jQuery event.pageY

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Event object · jQuery 1.0.4+

What You’ll Learn

event.pageY is a Number property with the pointer’s vertical position relative to the document’s top edge — scroll included. This tutorial covers the official mousemove demo, pairing with pageX, comparing with clientY, click pins, vertical drag, and scroll-aware positioning.

01

Property

event.pageY

02

Returns

Number (px)

03

Official

mousemove log

04

Document

Top edge

05

pageX

Horizontal pair

06

Since 1.0.4

Mouse events

Introduction

When the user moves or clicks the mouse, you often need to know where the pointer was. jQuery forwards coordinate properties from the browser on its event object — including event.pageY for vertical document position.

Unlike viewport coordinates (clientY), pageY counts pixels from the top edge of the full document, so it stays consistent when the page is scrolled. jQuery has exposed it since version 1.0.4.

Understanding event.pageY

This property answers one question: how far down is the pointer from the document’s top edge?

  • Origin — top edge of the document (not the viewport, not the clicked element).
  • Includes scroll — vertical scroll offset is included in the value.
  • Read-only — a Number in pixels; not a method.
  • Pair with pageX — use both for full document coordinates.
💡
Beginner Tip

Think of the document as a long page. pageY is how many pixels from the top of that page the mouse sits — even if you scrolled down to see content lower on the page.

📝 Syntax

Official jQuery API form (since 1.0.4):

jQuery
event.pageY

// typical pattern:
$( document ).on( "mousemove", function ( event ) {
  console.log( "X:", event.pageX, "Y:", event.pageY );
});

Parameters

  • NonepageY is a property, not a function.

Return value

  • Number — vertical mouse position in pixels relative to the top edge of the document.

Official jQuery API example

jQuery
$( document ).on( "mousemove", function ( event ) {
  $( "#log" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );
});

⚡ Quick Reference

PropertyRelative toAxis
event.pageXDocument left edgeHorizontal
event.pageYDocument top edgeVertical
event.clientXViewport left edgeHorizontal
event.clientYViewport top edgeVertical
event.offsetYTarget elementVertical (local)

📋 pageY vs clientY vs offsetY

Three vertical coordinates — same click, different reference frames.

pageY
event.pageY

Document — scroll included

clientY
event.clientY

Viewport — visible window

offsetY
event.offsetY

Event target element

pageX
event.pageX

Horizontal document coordinate

Examples Gallery

Example 1 follows the official jQuery mousemove demo. Examples 2–5 cover click pins, scroll comparison, drag tracking, and coordinate readouts.

📚 Official jQuery Demo

Log pageX and pageY on every mousemove — focus on the vertical value.

Example 1 — Official Demo: mousemove coordinates

Official jQuery demo — update a log with document X and Y on mousemove.

jQuery
$( document ).on( "mousemove", function ( event ) {
  $( "#log" ).text( "pageX: " + event.pageX + ", pageY: " + event.pageY );
});
Try It Yourself

How It Works

Each mousemove dispatch includes fresh pageX / pageY values from the browser. pageY grows as you move down the document and includes any vertical scroll offset.

Example 2 — Click pin: place marker using pageY

On canvas click, position an absolute marker using document coordinates.

jQuery
$( "#canvas" ).on( "click", function ( event ) {
  $( "#pin" ).css({
    left: event.pageX + "px",
    top: event.pageY + "px"
  });
  $( "#coords" ).text( "Pinned at pageY: " + event.pageY );
});
Try It Yourself

How It Works

Absolutely positioned elements use document coordinates when position: absolute relative to the document body — pageY maps directly to top.

📈 Practical Patterns

Scroll comparison, drag, and HUD readouts.

Example 3 — Scrolled page: pageY vs clientY

Log both vertical coordinates — after scrolling down, pageY and clientY diverge because pageY includes scroll offset.

jQuery
$( document ).on( "click", function ( event ) {
  $( "#compare" ).html(
    "pageY: " + event.pageY + " (document)
" + "clientY: " + event.clientY + " (viewport)" ); });
Try It Yourself

How It Works

pageY adds scroll offsets — roughly clientY + document scrollTop. Pick page coordinates for document-absolute placement.

Example 4 — Drag: track vertical delta with pageY

Store start pageY on mousedown; update top using difference on mousemove.

jQuery
var startY, startTop;

$( "#box" ).on( "mousedown", function ( event ) {
  startY = event.pageY;
  startTop = parseInt( $( this ).css( "top" ), 10 ) || 0;
  $( document ).on( "mousemove.drag", onDrag );
});

function onDrag( event ) {
  $( "#box" ).css( "top", startTop + ( event.pageY - startY ) );
}
Try It Yourself

How It Works

Deltas from pageY are scroll-stable — the difference between two pageY readings equals pointer movement in document space.

Example 5 — HUD: pageY under cursor on hover

Show a floating readout with vertical document coordinate over a chart area.

jQuery
$( "#chart" ).on( "mousemove", function ( event ) {
  $( "#hud" )
    .text( "pageY: " + Math.round( event.pageY ) )
    .css({ left: event.pageX + 12, top: event.pageY + 12 })
    .show();
});

$( "#chart" ).on( "mouseleave", function () {
  $( "#hud" ).hide();
});
Try It Yourself

How It Works

Long pages and timelines often map pageY (adjusted by element offset) to scroll depth or row index — the HUD demonstrates live vertical document position.

🚀 Common Use Cases

  • Coordinate display — show pointer X/Y in debugging HUDs.
  • Image annotation — place pins at click pageX / pageY.
  • Drag and drop — compute movement deltas with page coordinates.
  • Drawing apps — line tools using document-space points.
  • Heatmaps — log click positions for analytics.
  • Scroll depth — map pageY to how far the user has read down a page.

🧠 How pageY Works

1

Pointer event

User moves or clicks — browser fires mousemove, click, etc.

Event
2

Browser computes

Native event gets pageY from viewport position plus vertical scroll offset.

Native
3

jQuery handler

Your .on() callback reads event.pageY as a Number.

Read
4

Position UI

Place markers, drag elements, or map Y to scroll depth — scroll-aware document space.

📝 Notes

  • Available since jQuery 1.0.4 — returns a Number (pixels).
  • Read-only property on mouse events.
  • Relative to the document top edge, not the clicked element.
  • Always pair with pageX for 2D document coordinates.
  • Use clientY for fixed viewport overlays; offsetY for local element coords.
  • jQuery normalizes coordinates consistently across supported browsers.

Browser Support

event.pageY is forwarded on jQuery’s event object since jQuery 1.0.4+ for mouse events. Underlying values come from the DOM MouseEvent pageY property — supported in all browsers jQuery targets.

jQuery 1.0.4+ · all browsers

jQuery event.pageY

Vertical pointer position in document space.

100% Universal
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
pageY Number (px)

Bottom line: Read event.pageY on mousemove or click — document top edge origin.

Conclusion

event.pageY gives the pointer’s vertical distance from the document’s top edge — the official demo logs it alongside pageX on mousemove.

Use it for scroll-stable positioning, vertical drag deltas, and click annotations — and choose clientY or offsetY when your reference frame is the viewport or a single element.

💡 Best Practices

✅ Do

  • Use pageX + pageY for document-absolute placement
  • Compute drag deltas with differences of pageY readings
  • Round for display: Math.round(event.pageY)
  • Subtract element offset when mapping to local chart data
  • Prefer page coords when the page may scroll during interaction

❌ Don’t

  • Call event.pageY() with parentheses
  • Confuse pageY with clientY after scrolling
  • Use pageY on keyboard-only events for pointer position
  • Assume pageY is relative to the clicked child — use offsetY
  • Assign to event.pageY — it is read-only

Key Takeaways

Knowledge Unlocked

Five things to remember about pageY

Document vertical mouse coordinate.

5
Core concepts
doc 02

Document

Top edge

Origin
demo 03

Official

mousemove

Demo
X 04

pageX

Horizontal pair

Pair
vs 05

clientY

Viewport

Compare

❓ Frequently Asked Questions

event.pageY is a Number property on the jQuery event object. It returns the mouse pointer's vertical coordinate relative to the top edge of the document — including scrolled content. Available since jQuery 1.0.4 on mouse events such as mousemove, click, and mousedown.
clientY is relative to the browser viewport (visible window). pageY includes vertical scroll offset — pageY equals clientY plus the document's vertical scroll. Use pageY when you need document-wide vertical coordinates; clientY for viewport-fixed UI.
pageY is vertical (distance from the document's top edge). pageX is horizontal (distance from the document's left edge). Together they give a full (x, y) point in document space — the official jQuery demo logs both on mousemove.
Mouse events expose pageY — including mousemove, mouseenter, mouseleave, mouseover, mouseout, mousedown, mouseup, and click. Keyboard events do not have meaningful pageY values for pointer position.
No. pageY is read-only — the browser sets it from the pointer position when the event fires. To move UI, read pageY and apply the value to your own variables or CSS.
pageY is relative to the entire document. offsetY is relative to the event target element's padding edge. Use pageY for absolute document positioning; offsetY for clicks inside a specific box.
Did you know?

The official jQuery event.pageY demo logs vertical position on every mousemove — scroll down and watch pageY stay consistent with document space while clientY resets relative to the viewport.

Next: event.relatedTarget

Learn the other DOM element involved in mouseover and mouseout.

event.relatedTarget tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful