I'd try something like this:
$('#Directorships td:nth-child(1)').filter(function() {
return $(this).text() == 'D';
}).addClass('bgHighlight');
Change the 1 in :nth-child(1) to whatever column you want. nth-child
is 1-indexed, so the first cell in a row would be :nth-child(1), the
second :nth-child(2) and so on.
If it's the first or last column that you want highlighted, you could
use :first-child or :last-child, respectively.
--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Dec 5, 2009, at 12:50 PM, [email protected] wrote:
I have a table with an id of Directorships and I want to add the class
bgHighlight to any cell with a value of 'D'. This code below works
fine for an entire table but I just want to apply this logic to a
single column of the same table rather than the whole table. Thanks.
$('#Directorships tr').each(function() {
$('td', this).each(function() {
if ($(this).text() == "D")
$(this).addClass("bgHighlight");
});
});