3zzy 3zzy -4 years ago 89
jQuery Question

Selecting specific cells

$('table.listings td:contains("You")').each(function(){
$(this).children('td:nth-child(2)').addClass('highlighted');
});


I have multiple
table.listings
on the page but the one that contains "You" is selected and I want to addClass
highlighted
to the 2nd cell in each row, but the above code isn't working as I expected.

Answer Source
$('table.listings:contains("You") td:nth-child(2)').addClass("highlight");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download