Shades88
Shades88

Reputation: 8360

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

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 ?

Upvotes: 59

Views: 82235

Answers (3)

supakeen
supakeen

Reputation: 2914

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

Like so for the 3rd.

Upvotes: 12

user917670
user917670

Reputation: 871

the eq api should do this for you

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

Upvotes: 19

Haim Evgi
Haim Evgi

Reputation: 125496

using :nth-child() Selector

like

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

Upvotes: 112

Related Questions