Web API | DOMRect right property
In Web API there is a DOMRect Interface which has a property right which gives us the right of the DOMRect object. It returns x + width coordinate value or if the width is negative than it returns x.
Syntax:
var recX = DOMRect.right;
Return Type:
Double value
Example 1: When the width is positive
<!DOCTYPE html> <html> <head> <title> DOMRect right property </title> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect right property</h2> <button onclick="getDOMRect ();"> Get right </button> <p id='DOMRect'></p> </center> </body> <script type="text/javascript"> function getDOMRect() { var myDOMRect = new DOMRect(0, 0, 100, 100); var recright = myDOMRect.right; document.getElementById( 'DOMRect').innerHTML = recright; } </script> </html> |
Output:
Before clicking the button:

After clicking the button:

Example 2: When the width is negative
<!DOCTYPE html> <html> <head> <title> DOMRect right property </title> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect right property</h2> <button onclick="getDOMRect ();"> Get right </button> <p id='DOMRect'></p> </center> </body> <script type="text/javascript"> function getDOMRect() { var myDOMRect = new DOMRect(0, 0, -100, 100); var recright = myDOMRect.right; document.getElementById( 'DOMRect').innerHTML = recright; } </script> </html> |
Output:
Before clicking the button:

After clicked the button:

Supported Browsers: The browsers supported by DOMRect right property are listed below:
- Google Chrome
- Safari 10.1
- Firefox
- Opera
Recommended Posts:
- Web API | DOMRect top property
- Web API | DOMRect width property
- Web API | DOMRect left property
- Web API | DOMRect bottom property
- Web API | DOMRect height property
- Web API | DOMRect fromRect property
- Web DOMRect API | DOMRect() Constructor
- CSS | transition-property Property
- CSS | top Property
- CSS | right Property
- CSS | nav-right property
- CSS | nav-down property
- CSS | all Property
- CSS | nav-up property
- CSS | max-width 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.



