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

ページに複数table.listingsありますが、「あなた」を含むものが選択されており、各行の2番目のセルにClassを追加したいのですhighlightedが、上記のコードが期待どおりに機能していません。

4

3 に答える 3

0

Try this:

$('table.listings td:contains("You")').each(function(){
    $("td:nth-child(2)", $(this).parent().parent().get(0)).addClass('highlighted');
});
于 2010-02-08T04:50:46.993 に答える
0
$('table.listings :contains("You")').each(function(){
 $(this).children('td:nth-child(2)').addClass('highlighted');
});
于 2010-02-08T04:53:00.047 に答える
0
$('table.listings:contains("You") td:nth-child(2)').addClass("highlight");
于 2010-02-08T05:13:25.170 に答える