Web API DOMRectReadOnly y property
Last Updated :
15 Jun, 2023
The y property in the DOMRectReadOnly interface is used to represent the y-coordinate of the DOMRect object. It is a read-only property.
Syntax:
let recX = DOMRect.y;
Return Value: It returns the y-coordinate of the DOMRectReadOnly object.
Example: This example uses DOMRect.y property to get the y-coordinate of the DOMRect object.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
Web API DOMRectReadOnly y property
</ title >
</ head >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 >Web API DOMRectReadOnly y property</ h2 >
< button onclick = "getDOMRect ();" >
Get y-coordinate
</ button >
< p id = 'DOMRect' ></ p >
< script type = "text/javascript" >
function getDOMRect() {
let myDOMRect = new DOMRect(0, 0, 100, 100);
let recY = myDOMRect.let
document.getElementById('DOMRect').innerHTML
= recY;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browsers supported by DOMRectReadOnly y property are listed below:
- Google Chrome 61
- Edge 79
- Firefox 31
- Safari 10.1
- Opera 48
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...