MouseEvent clientY Property

Definition and Usage

When a mouse event is triggered, the clientY property returns the vertical coordinate of the mouse pointer (based on the client area).

The client area is the current window.

Tip:To get the horizontal coordinate of the mouse pointer (based on the client area), use clientX Property.

Note:This property is read-only.

Example

Example 1

Output the mouse pointer's coordinates when the mouse button is clicked on the element:

var x = event.clientX;     // Get the horizontal coordinate
var y = event.clientY;     // Get the vertical coordinate
var coor = "X coords: " + x + ", Y coords: " + y;

Result:

X coords: 142, Y coords: 99

Try It Yourself

Example 2

Output the mouse pointer's coordinates when the mouse pointer moves over the element:

var x = event.clientX;
var y = event.clientY; 
var coor = "X coords: " + x + ", Y coords: " + y;
document.getElementById("demo").innerHTML = coor;

Try It Yourself

Example 3

Demonstrate the difference between clientX and clientY as well as screenX and screenY:

var cX = event.clientX;
var sX = event.screenX;
var cY = event.clientY;
var sY = event.screenY;
var coords1 = "client - X: " + cX + ", Y coords: " + cY;
var coords2 = "screen - X: " + sX + ", Y coords: " + sY;

Try It Yourself

Syntax

event.clientY

Technical Details

Return Value: A numeric value representing the vertical coordinate of the mouse pointer, in pixels.
DOM Version: DOM Level 2 Events

Browser Support

Property Chrome IE Firefox Safari Opera
clientY Support Support Support Support Support

Related Pages

HTML DOM Reference Manual:MouseEvent clientX Property

HTML DOM Reference Manual:MouseEvent screenX Property

HTML DOM Reference Manual:MouseEvent screenY Property

HTML DOM Reference Manual:MouseEvent offsetX Property

HTML DOM Reference Manual:MouseEvent offsetY Property