Checking for text objects in body using jquery

I need to quickly check if there are any text nodes on the page , excluding space. Preferably, I would like to see if there is a way to do this with jQuery and be cross-browser.

thanks

+1


a source to share


1 answer


if( $.trim($("body").text()).length > 0 ){
  ...
}

      

or, if you want to exclude all spaces ...



$("body").text().replace(/\s/g,'').length > 0 ){

      

+3


a source







All Articles