JSFiddle - React, Tailwind, and code Playground
by ncapito
HTML
<p id='1'></p>
<hr />
<p id='1a'><br /></p>
<hr />
<p id='3success'><b>Match this</b></p>
<hr />
<p id='3successa'>
<b>Match this</b>
</p>
<hr />
<p id='3fail'><b>Match this</b> but not now because of this test</p>
<hr />
JavaScript
var getNontextNodes;
getNontextNodes = function(nodes) {
var cnt, n, _i, _len;
cnt = 0;
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
n = nodes[_i];
if (n.textContent.trim()) {
cnt++;
}
}
return cnt;
};
$("p").each(function () {
if (
(this.children.length === this.childNodes.length)
||
(getNontextNodes(this.childNodes) ===this.children.length)
) $(this).append("<b style='color:green'>Success</b>");
else $(this).append("<b style='color:red'>Failed</b>");
});