我有以下示例表代码,
<table id="Table1"> <thead> <th>Title</th> </thead> <tbody> <tr> <td>Row 1</td> </tr> <tr> <td>Row 2</td> </tr> <tr> <td>Row 3</td> </tr> <tr class='disabled'> <td>Row 4</td> </tr> <tr> <td>Row 5</td> </tr> </tbody> </table>
我在jQuery Sortable下面申请,工作正常,
$("#Table1 tbody").sortable({ });
但是,现在我想排除类别为“禁用”的“tr”排序,我要应用下面的代码(jquery选择器),但它不起作用.选择器有什么问题吗?我必须在HTML表格中使用“thead”和“tbody”.
或者有其他方法吗?谢谢,
$("#Table1 tbody tr:not(.disabled)").sortable({ });
解决方法
@H_502_17@ 使用items
选项:
Specify which items are eligible to sort by passing a jQuery selector
into the items option. Items excluded from this option are not
sortable,nor are they valid targets for sortable items.
$("#Table1 tbody").sortable({ items: 'tr:not(.disabled)' });