@technobuddha > react-hooks > DOM > Analysis
Function: measure()
ts
function measure(element: HTMLElement): Size;Defined in: measure.ts:21
Measures the size of an HTMLElement.
Parameters
| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | The HTMLElement to measure. |
Returns
Properties: width, height, scrollbarWidth, scrollbarHeight.
Example
typescript
const el = document.getElementById('myDiv');
if (el) {
const size = measure(el);
// size: { width: 1024, height: 768, scrollbarWidth: 16, scrollbarHeight: 16 }
}