在 jQuery 中,如果你想使用 :not() 选择器来排除表格行 (tr) 中的多个条件,有几种方法可以实现。

方法一:链式使用多个 :not()

$('tr').not('.class1').not('.class2')

或者:

$('tr:not(.class1):not(.class2)')

方法二:在单个 :not() 中使用多个选择器

$('tr:not(.class1, .class2)')

实际示例

假设你有一个表格,想选择所有不包含 "hidden" 类且不是第一个子元素的行:

$('tr:not(.hidden, :first-child)')

或者排除具有特定属性和类的行:

$('tr:not([data-ignore], .disabled)')

注意事项

  1. 选择器之间是"或"的关系,不是"与"的关系

  2. 选择器性能:复杂的选择器可能影响性能,特别是在大型表格中

  3. 可以结合其他选择器使用,如 $('table#myTable tr:not(.hidden, .deleted)')