YUI3: Whats the best way to read Height of an element?

4.3k Views Asked by At

I want to increase height of an element by X pixels by writing a YUI3 script.

Whats the best way ?

if I use 'Node' module and read the height as node.getStyle("height");

The results of FF3 shows a string "100px" where as for IE8 its just blank. :(

Please help.

1

There are 1 best solutions below

1
On BEST ANSWER

node.getStyle('height') only returns a value when you have a value set in the style of the node. To get the height of a node with out a style set use node.getComputedStyle('height') or node.get('clientHeight').

If you have overflow set, you can use node.get('scrollHeight') to get the full height of the content.

To update the height of the node, use setStyle('height', value)