Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get calculated element width and height in YUI3?

Tags:

jquery

dom

yui

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?

like image 774
Jaanus Avatar asked Jun 14 '10 18:06

Jaanus


People also ask

How do you find the width of an element?

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.

How do you find the height of a DOM element?

Use offsetWidth & offsetHeight properties of the DOM element to get its the width and height.

How do you find the width of a div?

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.


1 Answers

getComputedStyle

.getComputedStyle("width")
.getComputedStyle("height")
like image 108
Tivac Avatar answered Oct 04 '22 03:10

Tivac