My current task involves dynamically creating HTML elements using JavaScript. Here is an example:
var newElement = document.createElement("div");
newElement.innerHTML = _data[i].content;
newElement.className = "custom";
When the element has not been added to the document yet, the browser returns offsetHeight = 0
.
Before appending these elements to the document, I need to determine their height programmatically. This is important because if the resulting height exceeds a certain threshold, I will need to resize the element before adding it to the page.