JSFiddle - React, Tailwind, and code Playground
HTML
<div>something else
<div>test</div>
</div>
JavaScript
alert($('div:contains("test")').length);
<div>something else
<div>test</div>
</div>
alert($('div:contains("test")').length);