An HTML element can be hidden with the help of .hide() jQuery function or we can hide easily by making visibility equals hidden in CSS. We can easily find the height of this hidden element in jQuery.
There are two kinds of height that are defined with the every HTML element i.e, innerHeight and the outerHeight of the element:
html
Output:
Before Click:
After Click:
Here, border width will not be added to the result.
Example-2: This example show how to calculate outerHeight of the hidden element.
html
Output:
Before Click:
After Click:
Here, border width will be added to the result.

- innerHeight: This height is considered when the width of the border is not considered for the selected element.
- outerHeight: This height is considered when the width of the border is considered for the selected element.
<!DOCTYPE html>
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
$(document).ready(function() {
$("#btn1").click(function() {
var demo = $("div").innerHeight();
$("#demo").text(demo);
});
});
</script>
<style>
div {
width: 310px;
height: 80px;
font-weight: bold;
color: green;
font-size: 25px;
border: 1px solid green;
visibility: hidden;
}
body {
border: 1px solid green;
padding: 10px;
width: 300px;
}
</style>
</head>
<body>
<div>
</div>
<p id="demo">
Here the height of the
hidden "div" element will appear.
</p>
<button id="btn1">Submit</button>
</body>
</html>
After Click:
Here, border width will not be added to the result.
Example-2: This example show how to calculate outerHeight of the hidden element.
<!DOCTYPE html>
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
$(document).ready(function() {
$("#btn1").click(function() {
var demo = $("div").outerHeight();
$("#demo").text(demo);
});
});
</script>
<style>
div {
width: 310px;
height: 80px;
font-weight: bold;
color: green;
font-size: 25px;
border: 1px solid green;
visibility: hidden;
}
body {
border: 1px solid green;
padding: 10px;
width: 300px;
}
</style>
</head>
<body>
<div>
</div>
<p id="demo">
Here the height of the hidden
"div" element will appear.
</p>
<button id="btn1">Submit</button>
</body>
</html>
After Click:
Here, border width will be added to the result.
