The .not() traversing method excludes elements from the current jQuery collection — it keeps everything that does not match your selector, callback, DOM node, or jQuery object. This tutorial covers the official list and div demos, DOM-element exclusion, comparisons with .filter() and .is(), and callback-based removal.
01
Exclude
Remove matches
02
Selector
.not(".x")
03
Callback
Since 1.4
04
DOM node
Remove one
05
vs .filter()
Inverse
06
Since 1.0
Core API
Fundamentals
Introduction
Often you need to act on almost every element in a selection — all list items except one, all divs except green and blue, all inputs except disabled ones. The .not() method removes unwanted elements from the current set so you can style or manipulate the rest.
Available since jQuery 1.0 (callback and jQuery-object forms since 1.4), .not() is the inverse of .filter(). Where .filter() keeps matches, .not() keeps non-matches. The returned jQuery object is a new subset — the original collection is unchanged until you reassign the variable.
Concept
Understanding the .not() Method
Given a jQuery object representing a set of DOM elements, .not(selectorOrFunctionOrElement) tests each element against the argument. Elements that match are dropped; everything else stays in the result. With a callback, returning true excludes the element — the opposite of .filter(), where true means keep.
This is set narrowing, not tree traversal. .not() only considers elements already in the current collection — it does not search descendants or siblings. Compare with .find(), which drills down, and .is(), which returns a boolean without changing the set.
💡
Beginner Tip
$("li").not(":nth-child(2n)") excludes even-position items — items 2 and 4 — leaving 1, 3, and 5. The same pattern with .filter(":nth-child(2n+1)") would keep the same result.
Foundation
📝 Syntax
General forms of .not:
jQuery
.not( selector )
.not( function )
.not( selection )
Parameters
selector — a string containing a selector expression, a DOM element, or an array of elements. Matching elements are removed from the set.
function — a callback receiving index and element. Elements for which the function returns true are excluded.
selection — an existing jQuery object. Elements in the current set that match nodes in this object are removed.
Return value
A new jQuery object containing elements from the current set that do not match the argument.
Official jQuery API list example
jQuery
$( "li" ).not( ":nth-child(2n)" ).css( "background-color", "red" );
// Red on items 1, 3, 5 — even-position items excluded
.not('.active') → gray on inactive items
.filter('.active') → blue on active items
How It Works
Together, .not('.active') and .filter('.active') partition the same list into inactive and active groups — mutually exclusive subsets covering the whole set.
Example 5 — Exclude Disabled Inputs with a Callback
Use the function form when exclusion logic is more than a simple selector.
Enabled inputs → .enabled-field class
Disabled inputs → excluded from result
How It Works
Returning true from the callback excludes the element. Here, disabled inputs are dropped; enabled ones receive the class — the callback mirror of .filter(function(){ return !this.disabled; }).
Applications
🚀 Common Use Cases
Skip one item — $("li").not("#skip") or DOM-node exclusion.
All except active — $(".tab").not(".active") for inactive tabs.
Form fields minus disabled — callback or .not(":disabled").
Exclude highlighted types — official pattern: $("div").not(".green, #blueone").
Remove known selection — $("p").not($("#selected")) when you already have a jQuery object.
Stripe inverse — $("tr").not(":nth-child(even)") for odd rows only.
🧠 How .not() Excludes From the Matched Set
1
Start with current set
jQuery object holds candidate elements.
Input
2
Test each element
Selector, callback, DOM node, or jQuery object.
Test
3
Drop matches
Matching elements are removed from the result.
Exclude
4
−
Return & chain
New subset — push stack for .end().
Important
📝 Notes
Available since jQuery 1.0 — callback and jQuery-object forms since 1.4.
Inverse of .filter() — same arguments, opposite keep/exclude logic.
Callback returning true excludes the element (opposite of .filter()).
Only narrows the current set — does not search descendants like .find().
With a CSS selector string, text and comment nodes are removed during filtering.
Pushes onto jQuery’s internal stack — pair with .end() to restore the previous set.
Compatibility
Browser Support
.not() has been part of jQuery since 1.0+ (function form since 1.4). It relies on selector matching with no browser-specific behavior beyond jQuery itself.
✓ jQuery 1.0+
jQuery .not()
Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery builds. Native equivalent: manual array filter — jQuery .not() integrates with the collection stack and selector engine.
100%With jQuery loaded
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 in any jQuery project. Use .not() to exclude; use .filter() when you need to keep matches.
Wrap Up
Conclusion
The jQuery .not() method removes elements from the current collection — keeping everything that does not match your selector, callback, DOM node, or jQuery object. It is the natural inverse of .filter() for set narrowing.
Remember the official list lesson: $("li").not(":nth-child(2n)") styles items 1, 3, and 5 by excluding even positions. Reach for .filter() when you want to keep matches, and .is() when you only need a true/false answer.
Use .not() when exclusion reads clearer than inverted .filter()
Pass DOM nodes when another API gave you a plain element reference
Combine comma selectors to exclude multiple types at once
Pair mentally with .filter() — opposite logic, same set
Call .end() after .not() when continuing on the full set
❌ Don’t
Use .not() when you need to keep matches — use .filter()
Confuse .not() with .remove() — .not() does not delete DOM nodes
Expect .not() to search inside elements — use .find() first
Return false from a callback expecting exclusion — true means exclude
Use .is() when you need a modified collection to chain further
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about .not()
Remove matches — keep the rest.
5
Core concepts
−01
.not()
Exclude
API
+02
.filter()
Inverse
Compare
?03
.is()
Boolean
Compare
fn04
Callback
true drops
Logic
DOM05
Node arg
Remove one
API
❓ 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. Same test, opposite result set.
.is() returns a boolean — true if at least one element in the set matches. .not() returns a new jQuery object with matching elements removed. Use .is() to test; use .not() to exclude and keep working with the remaining collection.
Yes, since jQuery 1.4. .not(domElement) removes that specific node from the set if present. .not($('#selected')) removes elements that match nodes in the jQuery object — useful when another library gave you a plain DOM reference.
.not(function(index, element) { ... }) runs once per element. If the function returns true, that element is excluded from the result. Inside the callback, this refers to the current DOM element — the opposite logic 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 — though you may chain .remove() or .hide() on the filtered result afterward.
Did you know?
jQuery added the callback form of .not() in version 1.4 alongside .filter(function) — same signature, inverted boolean meaning. Before that, developers often wrote .filter(function(){ return !condition; }); .not(function){ return condition; } expresses exclusion more directly.