$('table.listings td:contains("You")').each(function(){
$(this).children('td:nth-child(2)').addClass('highlighted');
});
我的网页,但包含“您”选择了一个多table.listings
,我想addClass highlighted
每一行中的第二小区,但上面的代码不工作,我预期。中选择特定的细胞
$('table.listings td:contains("You")').each(function(){
$(this).children('td:nth-child(2)').addClass('highlighted');
});
我的网页,但包含“您”选择了一个多table.listings
,我想addClass highlighted
每一行中的第二小区,但上面的代码不工作,我预期。中选择特定的细胞
$('table.listings:contains("You") td:nth-child(2)').addClass("highlight");
试试这个:
$('table.listings td:contains("You")').each(function(){
$("td:nth-child(2)", $(this).parent().parent().get(0)).addClass('highlighted');
});
$('table.listings :contains("You")').each(function(){
$(this).children('td:nth-child(2)').addClass('highlighted');
});
这会做事情有时甚至多余,'$( 'table.listings TD:包含( “您”)')',如果在同一个表包含更多''与“你”,那么里面的代码被执行更多的同一张表,做同样的事情。 – Reigel 2010-02-08 04:59:05
值得注意的是,问这个问题的人也是这么做的,所以很可能“你”只在桌子的一部分,或者他/她不在乎是否多次完成。 – icktoofay 2010-02-08 05:04:22
是的,但如果你看到问题,为什么不纠正它?..) – Reigel 2010-02-08 06:38:47