JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">
    <div class="x"></div>
</div>

JavaScript

$('#test').html($('#test').has('.x').length);