Francisco Noriega
Francisco Noriega

Reputation: 14574

How to select Direct Descendants of a Direct Descendant

I am trying to find the direct <tr>'s descendants of a the first direct <table> descendant of the <body>.

I am currently doing the following:

$("body > table:first > tr")

but this is returning 0 elements.

What would be the correct way to do it?

Note: There are no class or id in any of the elements. ( :( )

Upvotes: 1

Views: 114

Answers (1)

Shomz
Shomz

Reputation: 37701

For tables, there is another selector between the table and the tr elements: tbody.

So, what you need is this:

$("body > table:first > tbody > tr")

Upvotes: 3

Related Questions