Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
104
rated 0 times [  108] [ 4]  / answers: 1 / hits: 38919  / 8 Years ago, thu, august 11, 2016, 12:00:00

I want to get inner html height by JavaScript. Suppose I have



<div>Content</div>


either if the div font size has increased or many divs nested inside the parent, how do I get the height of parent div?



edit: even if the nested div has border and padding too.


More From » html

 Answers
21

If it must be in vanilla JS...



var height = document.getElementById('content').clientHeight;


That will not include any borders or scrollbars in the element, just padding. If you want to include borders and scrollbars you may use offsetHeight instead.


[#61063] Tuesday, August 9, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harveys

Total Points: 113
Total Questions: 88
Total Answers: 79

Location: Oman
Member since Fri, Dec 23, 2022
1 Year ago
;