A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/MouseEvent/clientY below:

clientY · WebPlatform Docs

clientY Summary

Gets the y-coordinate of the mouse pointer, relative to the upper-left corner of the viewport (that is, the user agent’s client area).

Property of dom/MouseEventdom/MouseEvent

Syntax

Note: This property is read-only.

var yCoordinate = event.clientY;
Return Value

Returns an object of type NumberNumber

The Y coordinate of the mouse cursor.

Examples

This example uses the clientY property to determine the mouse position relative to the window. The console shows the mouse position at all times.

<!doctype html>
<html>
 <head>
  <script>
function logClientCoords() {
  console.log("The x coordinate is: " + e.clientX + "The y coordinate is: " + e.clientY);
}
function logCursorPosition(e) {
  console.log("X = " + e.clientX + " Y = ' + e.clientY);
}
window.addEventListener("move", logCursorPosition, false);
window.addEventListener("click", logClientCoords, false)
  </script>
 </head>
 <body>
 </body>
</html>
Notes

Client coordinates do not reflect the scroll offset of the page. To get the mouse pointer’s coordinates relative to the upper-left corner of the document, use the pageX and pageY properties.

Related specifications
DOM Level 3 Events
Working Draft
Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4