JSFiddle - React, Tailwind, and code Playground

HTML

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

JavaScript

$(function() {
    var count = 0;  
    $("#test p").each(function(index){
        count = count + $(this).text().length;
        alert("count: " + count)
    });
 });