Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

MouseEvent.clientY — vertical viewport coordinate

MouseEvent.clientY is a read-only property that gives a mouse event’s vertical coordinate relative to the viewport. It does not describe a position relative to the target element or the physical screen.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

event.clientY

MouseEvent.clientY gives the vertical coordinate where an event occurred, relative to the viewport associated with that event. Read it as event.clientY, for example when handling mousemove or click. It is a read-only property.

The reference frame is the viewport, not the element targeted by the event. Do not confuse it with clientX, which describes the horizontal position, or screenY, whose reference frame is the screen. Always check the reference frame when interpreting coordinates.

The example creates a synthetic event with clientY: 120 and another without an explicit coordinate. The constructor initializes the property; you do not assign to it after creating the object. An omitted clientY defaults to 0. Creating the event does not move the actual mouse pointer.

Run the example in a browser console. The expected results are 120 followed by 0. This is a Web API, not a feature of ECMAScript itself; having Node 24 in a repository does not establish that MouseEvent is available in that environment.

Examples

const event = new MouseEvent("mousemove", { clientY: 120 });
const defaultEvent = new MouseEvent("mousemove");

console.log(event.clientY);
console.log(defaultEvent.clientY);

Result

120
0

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources