I have some child elements inside a div that gets the CSS display: none
applied to it and I want to find out what the child element dimensions are. How can I do thi
Use window.getComputedStyle()
var o = document.getElementById('output');
var wmd1 = document.getElementById('whats-my-dims1');
var wmd2 = document.getElementById('whats-my-dims2');
o.innerHTML = 'wmd1: "' + window.getComputedStyle(wmd1).getPropertyValue("width")
+ '", "'
+ window.getComputedStyle(wmd1).getPropertyValue("height")
+ '", wmd2: "'
+ window.getComputedStyle(wmd2).getPropertyValue("width") + '", "'
+ window.getComputedStyle(wmd2).getPropertyValue("height") + '"';
#some-hidden-div{
display: none;
}
.whats-my-dims{
display:block;
width: 69px;
height: 42px;
background-color: #f00;
}
Processing... :p
Sooo... How do I get the width and height of whats-my-dims1?
jsfiddle https://jsfiddle.net/h9b17vyk/3/