jQuery has handy .height() and .width() utilities to get calculated displayed size of a DOM element. It also has .position() to get coordinates. In YUI3 Node, I see that there are .getX(), .getY() and .getXY() utilities to get position, but I do not see anything for size (or can't look).
What's a good way to get element height and width in YUI3?
If you need to know the total amount of space an element occupies, including the width of the visible content, scrollbars (if any), padding, and border, you want to use the HTMLElement. offsetWidth and HTMLElement. offsetHeight properties. Most of the time these are the same as width and height of Element.
Use offsetWidth & offsetHeight properties of the DOM element to get its the width and height.
To measure the width of a div element we will utilize the offsetWidth property of JavaScript. This property of JavaScript returns an integer representing the layout width of an element and is measured in pixels.
getComputedStyle
.getComputedStyle("width")
.getComputedStyle("height")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With