Identifying an empty text node with jQuery + Javascript
- by b. e. hollenbeck
You'd think this was easy - but I'm having the hardest time with it.
Here's what I'm trying to identify:
<span class="cw-value-one"></span>
Here's what I'm using so far:
$('span.cw-value-one').each(function(){
var textNode = $(this).text();
var type = typeof textNode;
var len = textNode.length;
if($(this).is(':empty')){
$(this).siblings('span.cw-value-two').css({"position": "relative", "left": "1em"});
}
});
Ok, so textNode = "", type = string and len = 1 - none of which is helpful in identifying an empty text node, since a has a type of string and length of 1. The jQuery .is(':empty') is not working either.
So whow do you identify an empty text node in JQuery or plain ol' Javascript?