user686605
user686605

Reputation:

Select all td in tr with jQuery

How would I access all of the tds in a tr, knowing only the tr index. I am hoping to do this with the jQuery nth-child selector.

Upvotes: 6

Views: 11394

Answers (3)

Ahmad Alfy
Ahmad Alfy

Reputation: 13381

$("table tr:nth-child(x) td");

This will return all the td within the x you set

Upvotes: 0

karim79
karim79

Reputation: 342795

The uber-speedy .eq filter method is one way.

var $cells = $("#table tr").eq(index).find("td");

Upvotes: 6

Philippe Leybaert
Philippe Leybaert

Reputation: 171924

$("table tr:eq(5) td")

This returns all td elements in the 6th row of a table

Upvotes: 12

Related Questions