我正在使用可通过表格排序的 jQuery UI(工作正常)。我想让标题和最后一行固定(不可移动)。
jQuery UI 文档表明这可以使用项目选择器来完成,但我对语法感到困惑。
相关代码如下:
<script type="text/javascript">
$(function () {
$("#response_options tbody.content").sortable();
$("#response_options tbody.content").disableSelection();
});
</script>
<table id="response_options" class="data-table">
<tbody class="content">
<tr>
<th>Links</th><th>Response</th>
</tr>
<tr class="sortable-row">
<td>Edit</td>
<td>Item 1</td>
</tr>
<tr class="sortable-row">
<td>Edit</td>
<td>Item 2</td>
</tr>
<tr class="sortable-row">
<td>Edit</td>
<td>Item 3</td>
</tr>
<tr class="sortable-row">
<td>Edit</td>
<td>Item 4</td>
</tr>
<tr class="sortable-row">
<td>Edit</td>
<td>Item 5</td>
</tr>
<tr>
<td>Edit</td>
<td>Item 1</td>
</tr>
</tbody>
</table>
选择器进入.sortable(...):
$("#response_options tbody.content").sortable();
作为
$("#response_options tbody.content").sortable( items: ??? );
并且应该可以仅选择 class="sortable-row"的项目;但我再次对语法感到困惑。
最佳答案
这应该有效:
$("#response_options tbody.content").sortable({items: 'tr.sortable-row'});
关于jquery-ui - jQuery UI 可按固定行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5999613/