Name

x, y — NN n/a IE 4 DOM n/a

Synopsis

Read-only

Returns the horizontal and vertical pixel coordinates of the mouse pointer at the time the event occurred. The coordinate system is either a positioned element or the BODY element. A value of -1 is returned if the pointer was outside of the document area of the browser window.

Example

if (event.x < 20 && event.y < 30) {
    ...
}

Value

Integer.

Default

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.