我想将类“second-col”添加到每行中的所有第二个 TD,但这不起作用:
$('table.tst3 tbody td:eq(1)').addClass('second-col');
最佳答案
使用nth-child
相反,'eq
' 将 Reduce the set of matched elements to a single element
$('table.tst3 tbody td:nth-child(2)').addClass('second-col');
关于jquery - 使用 :eq 将类添加到所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1486326/