开发者

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

开发者 https://www.devze.com 2023-03-11 02:40 出处:网络
I\'m trying to select the first child of a first sibling in jquery but having开发者_StackOverflow some trouble getting it right:

I'm trying to select the first child of a first sibling in jquery but having开发者_StackOverflow 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.


Try this:

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

Check out the JQuery traversing documentation.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消