JSFiddle - React, Tailwind, and code Playground
HTML
<div id="div">
Here is some text
<br><br>
<b>More text</b>
</div>
JavaScript
function getTextNodeHeight(textNode) {
var height = 0;
if (document.createRange) {
var range = document.createRange();
range.selectNodeContents(textNode);
if (range.getBoundingClientRect) {
var rect = range.getBoundingClientRect();
if (rect) {
height = rect.bottom - rect.top;
}
}
}
return height;
}
var textNode = document.getElementById("div").firstChild;
alert(getTextNodeHeight(textNode));