jQuery UI Sortable - 如何包含/排除多个"项目"?

Tro*_*ame 6 jquery-ui items jquery-ui-sortable

我有一个jQuery UI Sortable函数的工作示例.我正在将它应用于HTML表来拖放和排序表行.它工作得很好,除了我想排除某些类的行是可排序的.使用items参数,我可以成功排除一个类("list-button-bar"该类),但我不能为我的生活找出如何排除多个类的语法.例如,我想要排除<th>和其他类<tr>.

这可能是文档中的一个,但我还不熟悉jQuery UI,甚至不知道要搜索什么.

这是工作代码:

<script>
    $(function() {
      $("#applications_list tbody.list-tbody").sortable({
        items: "tr:not(.list-button-bar)",
        cursor: 'crosshair'
      });
      $("#applications_list tbody.list-tbody").disableSelection();

    });
</script>
Run Code Online (Sandbox Code Playgroud)

And*_*ker 14

你试过用逗号吗?该items选项采用jQuery选择器:

  $("#applications_list tbody.list-tbody").sortable({
    items: "tr:not(.list-button-bar), :not(th)", // Excludes <tr>s without a class and <th>s
    cursor: 'crosshair'
  });
Run Code Online (Sandbox Code Playgroud)