Skip to content

Instantly share code, notes, and snippets.

@lolikroli
Last active December 30, 2015 17:59
Show Gist options
  • Save lolikroli/7864506 to your computer and use it in GitHub Desktop.
Save lolikroli/7864506 to your computer and use it in GitHub Desktop.
Get height and width of an element. From http://stackoverflow.com/questions/526347/css-javascript-how-do-you-get-the-rendered-height-of-an-element The same properties for width.
var h = document.getElementById('someDiv').clientHeight;//includes the height and vertical padding.
var h = document.getElementById('someDiv').offsetHeight;//includes the height, vertical padding, and vertical borders.
var h = document.getElementById('someDiv').scrollHeight;//includes the height of the contained document (would be greater than just height in case of scrolling), vertical padding, and vertical borders.
//properties for width are the same
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment