How can I select all elements without a given class in jQuery?

后端 未结 5 1993
小蘑菇
小蘑菇 2020-11-28 03:23

Given the following:

  • Item 1
  • Item 2
  • Item 3
相关标签:
5条回答
  • 2020-11-28 03:52

    Refer to the jQuery API documentation: not() selector and not equal selector.

    0 讨论(0)
  • 2020-11-28 03:53

    What about $("ul#list li:not(.active)")?

    http://api.jquery.com/not-selector/

    0 讨论(0)
  • 2020-11-28 04:00

    You can use the .not() method or :not() selector

    Code based on your example:

    $("ul#list li").not(".active") // not method
    $("ul#list li:not(.active)")   // not selector
    
    0 讨论(0)
  • 2020-11-28 04:02
    if (!$(row).hasClass("changed")) {
        // do your stuff
    }
    
    0 讨论(0)
  • 2020-11-28 04:05

    You could use this to pick all li elements without class:

    $('ul#list li:not([class])')
    
    0 讨论(0)
提交回复
热议问题