getWidth(element) -> Number

Finds and returns the computed width of element.

This method returns correct values on elements whose display is set to none either in an inline style rule or in an CSS stylesheet.

For performance reasons, if you need to query both width and height of element, you should consider using Element.getDimensions instead.

Note that the value returned is a number only although it is expressed in pixels.


<div id="rectangle" style="font-size: 10px; width: 20em; height: 10em"></div>

// -> 200