views:

63

answers:

1

Hi,

I need to check in some fast way if there is any text nodes on page, excluding white space. Preferably, I'd like to see if there is a way to do this with jQuery, and to be cross-browser.

Thanks

+3  A: 
if( $.trim($("body").text()).length > 0 ){
  ...
}

or, if you want to exclude all white space...

$("body").text().replace(/\s/g,'').length > 0 ){
duckyflip
+1 Heh, and I'd been thinking about doing this by checking every node individually. Very nice.
cletus
perfect, thank you
Andrija