Sometimes, we want to get full height of a clipped div with JavaScript.
In this article, we’ll look at how to get full height of a clipped div with JavaScript.
How to get full height of a clipped div with JavaScript?
To get full height of a clipped div with JavaScript, we use the offsetHeight
property.
For instance, we write
<div id="element" style="height: 20px; overflow: hidden">
<p id="innerElement">
content<br />content<br />content<br />
content<br />content<br />content<br />
content<br />content<br />content<br />
</p>
</div>
to add a div with content.
Then we write
const innerHeight = document.getElementById("innerElement").offsetHeight;
console.log(innerHeight);
to get the p element with getElementById
.
And then we get its height with the offsetHeight
property.
Conclusion
To get full height of a clipped div with JavaScript, we use the offsetHeight
property.