.not(selector|element|array) (since jQuery 1.0) and .not(function|selection) (since 1.4) build a new set without the rejected elements. Pass a selector, DOM node, array, jQuery object, or callback. Returns a new jQuery object; does not change the DOM by itself.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("li").not(":nth-child(2n)"); // odd items (official)
$("div").not(".green, #blueone"); // exclude green + #blueone
$("p").not("#selected"); // drop one id
$("li").not(function (i) { // callback: true → exclude
return i % 2 === 0;
});
// filter() → keep matches
// not() → drop matches
Call
What it does
Matched set
Starting collection to narrow
Selector / element / array
What to remove (1.0+)
Function / jQuery selection
Custom test or known set (1.4+)
Return value
New jQuery set (may be empty)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select a broad set (e.g. $("li") or $("div")).
Step 2
Call .not(selector) to remove matching elements.
Step 3
Or pass a DOM node / jQuery object / array (1.4+ for selection & function).
Return Value
Return Value
Description
Boolean
Often true or false depending on the match or state.
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — Official: $("li").not(":nth-child(2n)")
.not(".active") → inactive items [not]
.filter(".active") → active items [filter]
How It Works
not. Drops .active — inactive items remain.
filter. Keeps .active only.
Same class. Opposite collections from one rule.
Frequently Asked Questions
.not() removes elements from the current jQuery collection — it returns a new jQuery object containing only elements that do NOT match a selector, fail a callback test, or match a provided DOM element or jQuery object. It is the inverse of .filter().
.filter() keeps elements that match. .not() keeps elements that do not match. $("li").filter(".active") returns active items; $("li").not(".active") returns inactive ones.
.is() returns a boolean — true if at least one element matches. .not() returns a new jQuery object with matching elements removed. Use .is() to test; use .not() to exclude and keep chaining.
Yes, since jQuery 1.4. .not(domElement) removes that node if present. .not($("#selected")) removes elements that match nodes in the jQuery object.
.not(function(index, element) { ... }) runs once per element. If the function returns true, that element is excluded. Inside the callback, this refers to the current DOM element — opposite of .filter(), where true means keep.
No. .not() only changes which elements the jQuery object refers to. It does not remove nodes from the page unless you chain something like .remove() afterward.