»

Get Object Dimensions

Java Method

java
Element.getBoundingClientRect()

method will return an object containing the width, height, and some other useful values:

java
{ width: 960, height: 71, top: 603, bottom: 674, left: 360, right: 1320 }

Get the values separated in variables:

java
var element = document.getElementById('foo'); var positionInfo = element.getBoundingClientRect(); var height = positionInfo.height; var width = positionInfo.width;

Look at the source for more methods and related discussions.