Reputation: 627
I have a table in which I need to get the input type checkbox element from a specific row. I tried selecting it like so (let's say I am interested in the first row)
$('tr :nth-child(1):checkbox')
yet I get ALL inputs from the table , not just from the row I need . Any thoughts what I'm doing wrong ?
Upvotes: 1
Views: 1109
Reputation: 1429
Your selector is wrong. Try this:
$('tr:nth-child(1) :checkbox')
The pseudo-class nth-child
must apply to the selector tr
.
Upvotes: 1
Reputation: 9614
Simple:
$('tr').eq(0).find(':checkbox').doSomething();
for example (zero-based).
Your code is wrong because you have space after tr
and that means next selector is in child tree below table-row. Pseudo-selectors must be right after element they apply to, without the space, $('input:checkbox')
for example.
Upvotes: 0