Mike Sickler
Mike Sickler

Reputation: 34471

JQuery: How do I select the nth inputs in each row of a table?

I have a table with n columns, and n-2 inputs in each column. I want to iterate over a single column of inputs, but can't figure out how to select them.

Upvotes: 0

Views: 59

Answers (1)

Matt Ball
Matt Ball

Reputation: 360046

Use the nth-child() selector. For example, to get the third column of inputs:

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

Remember that, in accordance with the CSS spec, nth-child() is 1-indexed.

Upvotes: 2

Related Questions