Javatpoint Logo
Javatpoint Logo

Javascript offsetY property

Javascript offsetY property displays the y-coordinates or height of the given element. The read-only MouseEvent offsetY attribute returns the y-coordinate of the mouse cursor for the target element. We can add the event function on the div tag, web page, or other elements to display y-coordination.

Syntax

The following syntax works for the offset function. We can get the vertical value of the given element.

Return Value

It gives back a number that, in pixels, indicates the mouse pointer's vertical coordinate.

Examples

The following examples show the y-coordinate of the given elements.

Example1

The following example displays the height or y-coordinate of the paragraph <p> elements. These coordinates work with the function and mouse cursor. The property displays height up to the mouse cursor on the element.

Output

The image displays the y-coordinates of the paragraph <p> elements.

Javascript offsetY property

Example2

The following example displays the y-coordinate of the paragraph elements. This property works with the function and mouse cursor. The property displays height up to the mouse cursor on the alert box.

Output

The image displays the y-coordinates of the paragraph <p> elements.

Javascript offsetY property

Example3

The following example displays the y-coordinate of the body elements. This property works with the function and mouse cursor. The property displays height up to the mouse cursor on the alert box.

Output

The image displays the y-coordinates of the paragraph <p> elements.

Javascript offsetY property

Example4

The following example displays the height or y-coordinate of the entire web page. These coordinates work with the function and mouse cursor. The property displays height up to the mouse cursor of the <html> tag.

Output

The image displays the y-coordinates of the paragraph <p> elements.

Javascript offsetY property

Web Browsers Supported

The given browsers and its version supported the offset property.

  • Opera 12.1 or later
  • Internet Explorer version 9 and up
  • Google Chrome version 1 and up
  • Edge 12 or higher
  • Firefox 39 and above for
  • Apple Safari version 1 and above

Conclusion

The offsetY property helps to get the height or y-coordinates of the given elements. It helps users and developers to get responsive functions. It worked to get the exact height from the initial to the mouse cursor.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA