THE WORLD'S LARGEST WEB DEVELOPER SITE

MouseEvent offsetY Property

❮ DOM Events ❮ MouseEvent

Example

Click inside a DIV and output the y-coordinate of the click, relative to the DIV element:

var x = event.offsetY;
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The offsetY property returns the y-coordinate of the mouse pointer, relative to the target element.

Tip: To get the x-coordinate, use the offsetX property.

Note: This property is read-only.


Browser Support

Property
offsetY Yes 6 39 Yes Yes


Syntax

event.offsetY

Technical Details

Return Value: A Number, representing the vertical coordinate of the mouse pointer, in pixels

Related Pages

MouseEvent: offsetX Property

MouseEvent: clientX Property

MouseEvent: clientY Property

MouseEvent: screenX Property

MouseEvent: screenY Property


❮ DOM Events ❮ MouseEvent