开发者

best way to jQuery tree traversal?

开发者 https://www.devze.com 2023-03-23 02:47 出处:网络
I got the following code: <table border=1> <tbody> <tr> <td>issue</td> <td><a class=\"issueDrawer\" href=\"#\">view</a></td>

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

精彩评论

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