JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test">
<p>Text</p>
<p></p>
</div>
<button>Hide and show</button>
CSS
#test p {
background: yellow;
padding: 5px;
}
#test p:empty {
display: none !important;
}
JavaScript
$('button').on('click', function() {
$('p').hide().show();
});