user6331266
user6331266

Reputation:

jQuery Selector after id

i cant figure out the correct selector for a table.

  <tr id="test1">
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td colspan="2">\*SELECT THIS \*</td>
  </tr>

I want to select tr with id and chose the input of of the 2nd tr "*SELECT THIS*"

$("#test1").next()

So i'm inside the 2nd tr, but i want the td under this tr.

$("#test1").next().$("td") is not working.

Any ideas?

Upvotes: 4

Views: 87

Answers (3)

RAUSHAN KUMAR
RAUSHAN KUMAR

Reputation: 6006

use this

$("#test1").next().find('td');

Upvotes: 1

Mitya
Mitya

Reputation: 34556

$("#test1").next().children('td');

From the sibling, you then need to delve into its children. More concise would be:

$('#test1 + tr td');

Upvotes: 4

Kodie Grantham
Kodie Grantham

Reputation: 2032

Close! Use .children();

$("#test1").next().children('td');

Upvotes: 3

Related Questions