Skip to main content
deleted 6 characters in body
Source Link
user4617883
  • 1.5k
  • 2
  • 13
  • 23

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) {   var rect = elem.getBoundingClientRect();   console.log("height: " + rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) {   const rect = elem.getBoundingClientRect();   console.log(`height: ${rect.height}`); } 

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) {   var rect = elem.getBoundingClientRect();   console.log("height: " + rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) {   const rect = elem.getBoundingClientRect();   console.log(`height: ${rect.height}`); } 

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log("height: " + rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) { const rect = elem.getBoundingClientRect(); console.log(`height: ${rect.height}`); } 
added 13 characters in body
Source Link
user4617883
  • 1.5k
  • 2
  • 13
  • 23

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log("height: " + rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) { const rect = elem.getBoundingClientRect(); console.log(`height: ${rect.height}`); } 

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log(rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) { const rect = elem.getBoundingClientRect(); console.log(`height: ${rect.height}`); } 

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log("height: " + rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) { const rect = elem.getBoundingClientRect(); console.log(`height: ${rect.height}`); } 
added 218 characters in body
Source Link
user4617883
  • 1.5k
  • 2
  • 13
  • 23

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log(rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) { const rect = elem.getBoundingClientRect(); console.log(`height: ${rect.height}`); } 

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log(rect.height); } 

Another option is to use the getBoundingClientRect function. Please note that getBoundingClientRect will return an empty rect if the element's display is 'none'.

Example:

var elem = document.getElementById("myDiv"); if(elem) { var rect = elem.getBoundingClientRect(); console.log(rect.height); } 

UPDATE: Here is the same code written in 2020:

const elem = document.querySelector("#myDiv"); if(elem) { const rect = elem.getBoundingClientRect(); console.log(`height: ${rect.height}`); } 
Source Link
user4617883
  • 1.5k
  • 2
  • 13
  • 23
Loading