我使用一個jQuery移動錶行,當我放開行,我想獲得它具有類group_heading
Jquery - 按類別取得最近的TR ID?
最近的TR的ID當我移動行被釋放,我得到它的使用ID:
var row_id = $(row).prop('id');
console.log (row_id)
導致sprint_145975
如何獲得最近的TR來sprint_145975
與類group_heading
的ID?
這是表格佈局。
<tr id="present_sprints" class="group_heading nodrag">
<td colspan="4">LIST1</td>
</tr>
<tr id="sprint_145664" style="cursor: move;">
<td>First round - in sprint</td>
<td>2012-09-19</td>
<td>2012-09-27</td>
</tr>
<tr id="sprint_145975" class="toggler_row" style="cursor: move;">
<td>Third round</td>
<td>2012-10-04</td>
<td>2012-10-11</td>
</tr>
<tr id="sprint_145966" class="toggler_row" style="cursor: move;">
<td>Release prep</td>
<td>2012-10-20</td>
<td>2012-10-27</td>
</tr><tr id="sprint_145665" class="toggler_row" style="cursor: move;">
<td>Second round</td>
<td>2012-09-28</td>
<td>2012-10-04</td>
</tr>
<tr id="future_sprints" class="group_heading nodrag">
<td colspan="4">Future Sprints</td>
</tr>
<tr id="sprint_145964" class="toggler_row" style="cursor: move;">
<td>Fifth run</td>
<td>2012-10-27</td>
<td>2012-11-03</td>
</tr>
<tr id="sprint_145965" class="toggler_row" style="cursor: move;">
<td>Fourth round</td>
<td><input type="text" value="2012-10-13" <="" td="">
</td><td>2012-10-20</td>
</tr>
對於上面我的例子將期待得到ID =「present_sprints」
如果被移動行的ID是sprint_145965,我期望在最近的TR的ID with class group_heading爲future_sprints
我該怎麼做?
我已經試過:
$('#sprint_145975').closest('.group_heading).prop('id);
$('#sprint_145975').closest('tr.group_heading).prop('id);
但是,這並不會工作。
感謝
通過最近的你是什麼意思一個或下一個? – guradio