Is there anyway to get the height of a dynamic div using javascript?I have a dynamic div which is populated by contents dynamically.I want to know div's height each time. Can anybody help me to figure it out?
3 Answers
You can set/get the Height of DIV from height Property
Example Code is,
document.getElementById("demo").style.height; document.getElementById("demo").style.height="100px"; If you set height in CSS means, use JQuery.
Comments
You can use .height(), .innerHeight() or outerHeight() based on what you need.
.height() - returns the height of element excludes padding, border and margin.
.innerHeight() - returns the height of element includes padding but excludes border and margin.
.outerHeight() - returns the height of the div including border but excludes margin.
.outerHeight(true) - returns the height of the div including margin.