JSFiddle - React, Tailwind, and code Playground

HTML

<div>Has content</div>
<div><span>has children</span></div>
<div></div>
<div>    </div>

JavaScript

$.expr[':'].nocontent = function(obj, index, meta, stack){
    // obj - is a current DOM element
    // index - the current loop index in stack
    // meta - meta data about your selector
    // stack - stack of all elements to loop
   
    // Return true to include current element
    // Return false to explude current element
    return !($.trim($(obj).text()).length) && !($(obj).children().length)
};

$('div:nocontent').text('no content');