Web API DOMRect width property
In Web API there is a DOMRectReadOnly Interface which has a property width that gives us the width of the DOMRect object.
Syntax:
let recX = DOMRect.width;
Return Type:
Double value
Example: Getting the width of the DOMRect object created.
HTML
<!DOCTYPE html> < html > < head > < title > DOMRect width property </ title > </ head > < body > < h1 style = "color:green;" > w3wiki </ h1 > < h2 >DOMRect width property</ h2 > < button onclick = "getDOMRect ();" > Get width </ button > < p id = 'DOMRect' ></ p > < script type = "text/javascript" > function getDOMRect() { let myDOMRect = new DOMRect( 0, 0, 100, 100); let recwidth = myDOMRect.width; document.getElementById( 'DOMRect').innerHTML = recwidth; } </ script > </ body > </ html > |
Output:
Supported Browsers: The browsers supported by the DOMRect width property are listed below:
- Google Chrome
- Safari 10.1
- Firefox
- Opera