Some elements in my web application are having display none and I wish to find their actual height to do some computations. I am using jquery 1.6 library to find the height but it returns incorrect value for the height and width of hidden elements havin height in percentage. Here is a jsfiddle example for the same: http://jsfiddle.net/LT9fU/ Can anyone suggest the correct way to find the dimensions of hidden HTML elements.
Here is the jsfiddle example for reference
HTML:
<body>
<div class="wrapper">
<div class="vsbl"></div>
<div class="hdn"></div>
</div>
CSS:
.wrapper{
height:300px;
width:300px;
border:1px solid black
}
.vsbl,.hdn{
height:100px;
width:70%;
margin:10px;
border:1px solid black;
}
.hdn{
display:none;
}
Javascript:
$().ready(function(){
var content = "";
content += $(".vsbl").width() + "<br>";
content += $(".hdn").width();
document.body.innerHTML += content;
});
The output I got were 210 for visible block and 392 for hidden block.