JSFiddle - React, Tailwind, and code Playground
HTML
<div>string</div>
JavaScript
if( $('body:contains(string)').length ) {
console.log('found it');
};
<div>string</div>
if( $('body:contains(string)').length ) {
console.log('found it');
};