tags:

views:

66

answers:

1

I need to only find the cells in the table which contain   using jQuery.

 <table>
      <tr>
           <td>&nbsp;</td>
           <td>Something</td>
           <td>something else</td>
           <td>&nbsp;</td>
     </tr>
    </table>

Any ideas?

+3  A: 

Quick guess, maybe a better way

updated - thanks to Tomalak

var x = $('table tr td').filter( function(){
     return $(this).text() == String.fromCharCode(160); 
})
redsquare
  is char code 160. otherwise, +1. You beat me to it. ;-)
Tomalak
is it ok will update cheers
redsquare
And, I think you should use $(this).text().
Tomalak
hmm yeah I wondered that
redsquare
based off of this I found td:contains('" + String.fromCharCode(160) + "') to also work
Ross Goddard
Just to point out an alternative way of matching, that is more general: / /.test(this.innerHTML);
Mike
And when I recently needed to do something similar, I found there was often other white space, or nothing at all, so I needed to match like this: /^\s* \s*$|^$/.test(this.innerHTML);
Mike