The DOMRect() constructor in DOMRect API is used to create DOMRect object which represents a rectangle.
var myDOMRect = new DOMRect(x, y, width, height);
Parameters: This constructor contains four parameters as mentioned above and described below:
- x: It sets the x-coordinate of the rectangle.
- y: It sets the y-coordinate of the rectangle.
- width: It sets the width of the rectangle.
- height: It sets the height of the rectangle.
Example: This example creates a DOMRect object with given parameters.
- Before Click the button:
- After Click the Button console view:
Supported Browsers: The browsers supported by DOMRect() constructor are listed below:
- Google Chrome
- Safari 10.1