Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Web API | DOMRectReadOnly x property

  • Last Updated : 08 Aug, 2019

The x property in DOMRectReadOnly API interface is used to represents the x coordinate. It is a read-only property.


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> 
        Web API DOMRectReadOnly x property
<body style="text-align:center;">
    <h1 style="color:green;"
    <h2>Web API | DOMRectReadOnly x property</h2>
    <button onclick="getDOMRect ();">
        Get x-coordinate
    <p id='DOMRect'></p>
    <script type="text/javascript">
        function getDOMRect () {
            var myDOMRect = new DOMRect(0, 0, 100, 100);
            var recX = myDOMRect.x;
                    = recX;


  • 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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!