JSFiddle - React, Tailwind, and code Playground
HTML
<h3 class="hideIfDivEmpty">Title 1 (hidden)</h3>
<div></div>
<h3 class="hideIfDivEmpty">Title 2 (title 1 is hidden)</h3>
<div>This div has content, so it will not be hidden.</div>
JavaScript
$('h3.hideIfDivEmpty + div:empty').prev().hide();