JQuery (': not (selector )')
In earlier versions of jQuery, The: not () filter only supports Simple selectors, which means that the selector passed into the: not filter can be any complicated, for example: not (div) and: not (div,)
Copy codeThe Code is as follows:
<P> "a"> sdfsdfs </p>
<P> "B"> sdfsdfs </p>
<P> "c"> sdfsdfs </p>
$ ("P: not (. a)" ).css ({"color": "red "})
In addition to the p element whose class is equal to a, the text color of other P becomes red.
: Not () pseudo-class filtering selector, which is called the real interface. jQuery's: not () method is jQuery's pseudo-class selector, which can filter unwanted elements, filter out the correct results. In short, we have the following code:
Copy codeThe Code is as follows:
$ ("Selector1: not (selector2 )")
After analyzing the code above, we need to obtain the elements of selector1, but I may not need all of them. What should I do? Use the: not () method to filter them if the set of selector1 contains #1, #2, #3, #4
Our selector2 is to filter out #4. The above code will eventually get #1, #2, #3
A few more columns
Copy codeThe Code is as follows:
$ ('Li: not (: only-child) ') // matches all li, except
$ ('Li: not (: first-child) '); // matches the li
$ ("Li: not (: first)"). hide (); // hide all LI addresses except the first LI