JSFiddle - React, Tailwind, and code Playground
by paulL
HTML
<html id="root">
<body>
This is text.
<p><span class="other">This is bold text</span></p>
this is another text
</body>
</html>
JavaScript
function countText(node){
var counter = 0;
if(node.type === "text"){
counter+= node.value.length;
}
else{ typeof node;}
return counter;
};
alert("number of text:" + countText(doument.getElementById(root)));