.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.
Remember
$("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
Or pass a DOM node / jQuery object / array (1.4+ for selection & function).
Or use a callback — return true to exclude that element.
Chain styling or other methods on the remaining set.
Piece
Required?
Role
Matched set
Yes
Starting collection to narrow
Selector / element / array
One form
What to remove (1.0+)
Function / jQuery selection
One form
Custom test or known set (1.4+)
Return value
—
New jQuery set (may be empty)
Pseudocode
Pseudocode
call $(set).not(criterion)
result = empty set
for each element in set (with index i):
if criterion is a function:
exclude = criterion(i, element) is true
else if criterion is a selector:
exclude = element matches selector
else:
exclude = element is in criterion (node / array / jQuery)
if NOT exclude:
add element to result
return result as a new jQuery object
Reference
Cheat Sheet
Keep filtering methods side by side.
Topic
Detail
Syntax
.not(selector|fn|element|jQuery)
Since
1.0 · function & jQuery in 1.4
vs .filter()
Drop matches vs keep matches
Callback true
Means exclude
vs .is()
New set vs boolean
Official list demo
$("li").not(":nth-child(2n)")
DOM change?
No — query only
Try it
Live Preview
From five list items, compare .not(), .filter(), and a callback exclude.
list item 1
list item 2
list item 3
list item 4
list item 5
Official idea: .not(":nth-child(2n)") keeps items 1, 3, 5.
Result
Ready — choose a call and click Run.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official: $("li").not(":nth-child(2n)")
list item 1 [kept]
list item 2 [kept]
list item 3
list item 4 [kept]
list item 5 [kept]
How It Works
Reference. Get the third item as a plain DOM node.
Exclude..not(node) drops that node from the set.
Rest. Items 1, 2, 4, and 5 remain.
Use. Handy when another library hands you a DOM reference.
Edge Cases & Pitfalls
Why an excluded set can surprise you.
callback
Callback true excludes
Opposite of .filter(). Returning true means “remove this one.”
dom
Does not remove from the page
.not() only shrinks the jQuery collection. Chain .remove() if you need DOM deletion.
nodes
Selector form drops text/comment nodes
Official note: a CSS selector string always strips text and comment nodes from the result during filtering.
empty
Everything matched → empty set
If every element matches the criterion, .length is 0. Check length when that matters.
Compatibility
Browser Support
.not() has been part of jQuery since 1.0. The function and jQuery-object forms were added in 1.4. It works in every browser that runs your loaded jQuery version.
✓ Stable · jQuery 1.0+
jQuery .not()
Supported across jQuery 1.x, 2.x, and 3.x. Prefer a current jQuery 3.x build. Filtering operates on the current matched set only.
100%With jQuery
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.not()Universal
Bottom line: Safe for excluding classes, ids, or known nodes from a collection. Remember: callback true means exclude.
Analysis
Performance Notes
Approach
Cost
Best for
.not(selector)
Cheap
Drop by class / id / pseudo
.not(element)
Cheapest
Exclude one known node
.not(fn)
Per-element call
Custom rules
Narrower start set
Faster
Prefer $("ul li") over $("*")
Prefer a tight starting selector, then .not(), over selecting everything and filtering a huge set.
Remember
Key Takeaways
Role: remove matching elements from the current set.
vs filter: drop matches vs keep matches.
Callback: return true to exclude (1.4+).
DOM: collection only — not page removal.
One line:.not() keeps everything that does not match — the inverse of .filter().
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.