Web API | DOMRectReadOnly x property
The x property in DOMRectReadOnly API interface is used to represents the x coordinate. It is a read-only property.
Syntax:
var recX = DOMRect.x;
Return Value: It returns the x coordinate of DOMRectReadOnly API.
Example: This example uses DOMRect.x property to get the x-coordinate of the DOMRect object.
<!DOCTYPE html> <html> <head> <title> Web API DOMRectReadOnly x property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h2>Web API | DOMRectReadOnly x property</h2> <button onclick="getDOMRect ();"> Get x-coordinate </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect () { var myDOMRect = new DOMRect(0, 0, 100, 100); var recX = myDOMRect.x; document.getElementById('DOMRect').innerHTML = recX; } </script> <body> </html> |
chevron_right
filter_none
Output:
- Before Click the Button:

- After Click the Button:

Supported Browsers: The browsers supported by DOMRectReadOnly x property are listed below:
- Google Chrome
- Firefox
- Safari 10.1
- Opera
Recommended Posts:
- Web API | DOMRectReadOnly y property
- CSS | transition-property Property
- CSS | all Property
- CSS | nav-right property
- CSS | top Property
- CSS | nav-down property
- CSS | right Property
- CSS | padding-right Property
- Web API | DOMRect right property
- CSS | resize Property
- CSS | align-self Property
- CSS | perspective Property
- CSS | left Property
- CSS | grid-row Property
- CSS | clip Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



