Jquery如何使用行ID创建数组?

Rai*_*ner -1 javascript jquery

如何获取数组中表行的ID?

我想要的示例:

var rows = // IDs of rows 
Run Code Online (Sandbox Code Playgroud)

这是我的表格代码:http: //pastie.org/2675460

来自粘贴箱:

<table cellspacing="0" cellpadding="0" id="admintabel" style="width:980px;">
  <tbody><tr style="height: 40px; font-size: 14px; font-weight: bolder; font-family: Arial; cursor: move;">
    <th style="border-left:1px solid #CCCCCC">Navn</th>
    <th>Udbyder</th>
    <th>Kliks</th>
    <th>Pris md.</th>
    <th>Mindstepris</th>
    <th></th>
    <th></th>
    <th style="border-right:1px solid #CCCCCC"></th>
  </tr>

  <tr id="2" style="cursor: move;" class="">
    <td style="border-left:1px solid #CCCCCC">Der</td>
    <td>0</td>
    <td>1</td>
    <td> kr.</td>
    <td> kr.</td>
    <td><a class="viewlink" href="/bredbands/2"></a></td>
    <td><a class="editlink" href="/bredbands/2/edit"></a></td>
    <td style="border-right:1px solid #CCCCCC"><a rel="nofollow" data-method="delete" data-confirm="Are you sure?" class="deletelink" href="/bredbands/2"></a></td>
  </tr><tr id="1" style="cursor: move;">
    <td style="border-left:1px solid #CCCCCC">Te</td>
    <td>0</td>
    <td>0</td>
    <td>147 kr.</td>
    <td>148 kr.</td>
    <td><a class="viewlink" href="/bredbands/1"></a></td>
    <td><a class="editlink" href="/bredbands/1/edit"></a></td>
    <td style="border-right:1px solid #CCCCCC"><a rel="nofollow" data-method="delete" data-confirm="Are you sure?" class="deletelink" href="/bredbands/1"></a></td>
  </tr>

</tbody></table>
Run Code Online (Sandbox Code Playgroud)

如果使用我的表,数组将是[2,1]

ale*_*lex 7

我用map()get().

var ids = $('table tr[id]').map(function() { return this.id; }).get();
Run Code Online (Sandbox Code Playgroud)

jsFiddle.