Output the coordinates of the mouse pointer when the mouse button is clicked on an element:
The result of coor could be:
More "Try it Yourself" examples below.
The clientX property returns the horizontal coordinate (according to the client area) of the mouse pointer when a mouse event was triggered.
The client area is the current window.
Tip: To get the vertical coordinate (according to the client area) of the mouse pointer, use the clientY property.
Note: This property is read-only.
Property | |||||
---|---|---|---|---|---|
clientX | Yes | Yes | Yes | Yes | Yes |
Return Value: | A Number, representing the horizontal coordinate of the mouse pointer, in pixels |
---|---|
DOM Version: | DOM Level 2 Events |
Output the coordinates of the mouse pointer while the mouse pointer moves over an element:
A demonstration of the differences between clientX and clientY and screenX and screenY:
HTML DOM reference: MouseEvent clientY Property
HTML DOM reference: MouseEvent screenX Property
HTML DOM reference: MouseEvent screenY Property