I need to select elements without child node (including text since in text is a child node).
I used empty, but it also consider
empty
Try this
$("span").each(function(){ if($(this).text().trim()=='') $(this).text('Empty'); });
If you don't like each function then
$("span").html(function(){ if($(this).text().trim()=='') return 'Empty'; });