kinakuta
kinakuta

Reputation: 9037

best way to select a first sibling's first child in jquery?

I'm trying to select the first child of a first sibling in jquery but having some trouble getting it right:

<tr class="foo"></tr>
<tr>
  <td>

I have a handler attached to tr.foo and I want to do something to the td, but I'm not getting the selector right.

Upvotes: 1

Views: 6664

Answers (2)

Richard Schneider
Richard Schneider

Reputation: 35477

The selector tr + tr td selects the td that has a tr parent that is preceeded by another tr.

Upvotes: 1

jfocht
jfocht

Reputation: 1754

Try this:

$("tr.foo").next("tr").children("td").first()

Check out the JQuery traversing documentation.

Upvotes: 4

Related Questions