I want to calculate the height of an element (such div
) in px, using javascript when it hasn't it's default value (= initial
or auto
).
Note that my element has another value for its height now (such 40px), but I want to understand what would be its height (in pixels) if I set that to initial
or auto
.
In other words:
myElement.style.height = '40px'; // for example
// ...
console.log(myElement.clientHeight); // This logs "40". This is not the value I want.
myElement.style.height = 'initial';
console.log(myElement.clientHeight); // This logs the value I want. But I don't want to execute above statement AT ALL!