Javascript 如何使用jquery选择tr的第n个td

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7229145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 01:24:16  来源:igfitidea点击:

how to select n-th td of a tr using jquery

javascriptjqueryhtml

提问by Shades88

How can I select nth< td >of a < tr >using jquery. Say, I want to select 3rd< td >. I have id for every tr. How can we achieve this ?

如何选择第n< td >一个的< tr >使用jquery。说,我想选择3rd< td >。我有每个 tr 的 id。我们怎样才能做到这一点?

回答by Haim Evgi

using :nth-child()Selector

使用:nth-child()选择器

like

喜欢

$("tr td:nth-child(2)")

回答by user917670

the eq apishould do this for you

EQ API应该为你做这个

$("table td").eq(n)

回答by supakeen

$('#id td:nth-child(3)');

Like so for the 3rd.

第 3 次也是如此。