jQuery(':not(selector)')
In early versions of jQuery, the :not() filter only supports simple selectors, which means that the selector we pass into the :not filter can be arbitrary. Complex, such as: not(div a) and :not(div,a)
"a">sdfsdfs
"b">sdfsdfs
"c"> ;sdfsdfs
$("p:not(.a)").css({"color":"red"})
Then except that class is equal to p Outside the element, the text color of other P becomes red.
:not() pseudo-class filter selector. This name is really hard to pronounce. jQuery’s :not() method is jQuery’s pseudo-class selection The filter can filter out unnecessary elements and filter out the correct results. Simply put, we have the following code:
$("selector1:not(selector2)")
Let’s analyze the above code. We want to get the elements of selector1, but maybe I don’t need it. All, what to do, filter through the :not() method, if there are #1, #2, #3, #4 in the selector1 collection
Our selector2 is to filter out #4, the above code We will end up with #1, #2, #3
Just a few more examples
$('li:not(:only-child)')//Match all li, except
$('li:not(:first) which has only one child element -child)');//Match except LI which is the first child element in its parent element
$("li :not(:first)").hide();//Hide except the first one All LI except LI