Eastern Monk
Eastern Monk

Reputation: 6635

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

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.

Upvotes: 6

Views: 4306

Answers (1)

apipkin
apipkin

Reputation: 166

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)

Upvotes: 13

Related Questions