开发者

best way to jQuery tree traversal?

I got the following code:

<table border=1>
  <tbody>
    <tr>
      <td>issue</td>
      <td><a class="issueDrawer" href="#">view</a></td>
      <td>description</td>
    </tr>
    <tr class="issueDrawer" style="display: none;"><td colspan="100%">boom!</td></tr>
    <tr>
      <td>issue</td>
      <td><a class="issueDrawer" href="#">view</a></td>
      <td>description</td>
    </tr>
    <tr class="issueDrawer" style="display: none;"><td colspan="100%">boom!</td></tr>
    <tr>
      <td>issue</td>
      <td><a class="issueDrawer" href="#">view</a></td>
      <td>descri开发者_Go百科ption</td>
    </tr>
    <tr class="issueDrawer" style="display: none;"><td colspan="100%">boom!</td></tr>
  </tbody>
</table>

Basically I'm performing an action on "a.issueDrawer" which should animate "tr.issueDrawer". From "a.issueDrawer" I'm currently doing $(this).parent().parent().next(), but there must be a cleaner way to travers up and find the first "tr.issueDrawer".

Thoughts?


Instead of .parent().parent(), you can use .closest('tr').

$(this).closest('tr').next('tr.issueDrawer')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜