JSFiddle - React, Tailwind, and code Playground
HTML
<div class="nav-previous">
</div>
CSS
.nav-previous {
border: 1px solid red;
}
.nav-previous:empty{
display: none;
}
.empty{
display: none;
}
JavaScript
(function($){
$.isBlank = function(html, obj){
return $.trim(html) === "" || obj.length == 0;
};
$('div').each(function() {
if($.isBlank(
$(this).html(),
$(this).contents().filter(function() {
return (this.nodeType !== Node.COMMENT_NODE);
})
)) {
$(this).addClass('empty');
}
});
})(jQuery);