Start with what you want, then subtract what you do not want.
Choose a base set — li, input, div, and so on.
Add :not(filter) with any valid selector inside.
Chain a method on the remaining matches.
If the filter string gets messy, switch to .not().
Piece
Required?
Role
Base selector
Usually
Elements to start from (optional if :not() stands alone)
:not(…)
Yes
Negation filter
Inner selector
Yes
What to exclude — any valid selector
Pseudocode
Pseudocode
candidates = find(baseSelector) // or all elements
result = empty set
for each element E in candidates:
if E does NOT match innerSelector:
keep E
return jQuery(result)
Reference
Cheat Sheet
Keep these facts handy while writing exclusions.
Topic
Detail
Syntax
$("base:not(filter)")
Meaning
Keep elements that fail the filter
Inner args
Any selector; commas exclude several
vs .not()
Selector string vs method on a set
Snapshot
Matches at query time only
Since
jQuery 1.0 (CSS3 + jQuery extensions)
Try it
Live Preview
Pick a :not() pattern against a small sample DOM and see what remains.
Sample markup mirrors the official unchecked-input demo plus class exclusions.
Active
Done
Plain
skip
draft
keep
Result
$("input:not(:checked)")
matched: 2
tags: INPUT, INPUT
/* keep elements that fail the filter */
Code
jQuery Examples
Short, copy-ready snippets. Open a browser console with jQuery loaded, or use Try It Yourself for a live editor.
Example 1 — Official Demo: input:not(:checked) + span
Select spans that sit right after unchecked inputs (jQuery API example).
Selector path.$("li:not(.active)") filters while querying.
Method path. Select all li, then remove .active with .not().
Same result. Lengths match on the same markup.
When to choose. Simple string → :not(). Existing set or complex filter → .not().
Edge Cases & Pitfalls
Check these before relying on :not() in real projects.
snapshot
Results do not auto-update
Official demo notes checkboxes do not re-style on click unless you re-query or bind events. Always re-run after state changes.
readability
Complex :not() strings get hard to read
jQuery recommends .not() when exclusions involve variables or long filters.
css
Native CSS :not() is stricter in older browsers
Early CSS only allowed simple selectors inside :not(). jQuery accepts broader forms; do not assume every jQuery string works in raw querySelectorAll everywhere.
base
Always scope the base set
$(":not(.x)") can be huge. Prefer $("li:not(.x)") or a container context.
Compatibility
Browser Support
:not() is supported in jQuery since 1.0. Modern browsers also implement CSS :not() in querySelectorAll; jQuery extends complex and comma-separated filters.
✓ CSS3 · jQuery 1.0+
jQuery :not(selector)
Supported in all modern browsers with jQuery. Prefer .not() for complex exclusions when readability matters.
100%Widely supported
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 with jQuery
Bottom line: Safe for jQuery apps. Keep filters simple in :not(); use .not() when the exclusion logic grows.
Analysis
Performance Notes
Approach
Cost
Best for
$("base:not(f)")
One query + filter
Simple static exclusions
$("base").not(f)
Select then subtract
Complex / dynamic filters
$(":not(f)")
Very broad
Avoid — always scope a base
Narrow the base selector first. Excluding from a small set is cheaper and clearer than starting from the whole document.
Remember
Key Takeaways
Role::not(filter) keeps elements that fail the filter.
Inner args: any selector; commas exclude several at once.
Method twin: prefer .not() for complex exclusions.
Snapshot: re-query after DOM or checked state changes.
One line:$("base:not(filter)") means “everything in base except what matches filter.”
Frequently Asked Questions
:not(selector) keeps elements that do not match the inner selector. $("li:not(.active)") returns every list item except those with class active.
jQuery accepts any valid selector inside the parentheses — elements, classes, IDs, attributes, and other pseudo-classes. Official docs show both :not(div a) and :not(div,a).
:not() is part of a CSS selector string. .not() is a method that removes items from an existing jQuery collection. For complex or dynamic exclusions, official docs recommend .not() for readability.
Yes. Use a comma-separated list: $("div:not(.skip, .draft)"). Each listed selector is excluded.
No. Like other selectors, it matches the DOM at query time. Recheck after user actions if state changes (for example, checkboxes).
Since jQuery 1.0. Modern browsers also support CSS :not() via querySelectorAll; jQuery extends complex and comma-separated cases.