JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">
    <p>Lorem Ipsum</p>
    <p>Lorem Ipsum</p>
</div>

JavaScript

var count = 0;
var ps = document.getElementsByTagName('p');
for (var i = 0; i < ps.length; i++) {
    var text = ps[i].textContent || ps[i].innerText;
    count += text.length;
}
alert("count: " + count)