JSFiddle - React, Tailwind, and code Playground
HTML
<div id="id1">
<p>
apple
</p>
<p>
ball
</p>
<p>
cat
</p>
<p>
dogsss
</p>
</div>
JavaScript
$('#id1 p').each(function() {
var text = $(this).text();
$(this).text(text.replace('dog', 'doll'));
});