JSFiddle - React, Tailwind, and code Playground

HTML

<div>something else
       <div>test</div>
    </div>

JavaScript

alert($('div:contains("test")').length);