One possible solution:
$('td').filter(function() {
return $(this).text().indexOf('Foo') === 0;
}).closest('tr');
You have to use .filter()
to work on the element's text (you can't do this with a selector, at least not the way you want to) and .closest()
should be self explaining.
Edit: But this could select a <tr>
elements multiple times. I actually don't know how jQuery handles this. Another solution would be to use two nested filter
s (on tr
and on td
but somehow this feels inefficient).
Edit2: From version 1.4.4 on, jQuery seems to be smart enough to deal with multiple occurances of the same element (i.e. it works like a set). DEMO here (if you change to version 1.4.2, you'll see that the first row gets selected twice).