The attribute not-equal selector — written [name!="value"] — matches elements that do not have the attribute set to your exact value. It also matches elements without that attribute. It is a jQuery extension (since 1.0), equivalent in intent to :not([attr="value"]).
01
Syntax
[attr!="x"]
02
Exclude
Not exact value
03
Missing
Attr absent too
04
Official
name!=newsletter
05
vs =
Inverse logic
06
.not()
Faster pattern
Fundamentals
Introduction
Sometimes you need to select everything except one known attribute value — all inputs that are not hidden fields, all links that are not target="_blank", or every radio that is not part of the newsletter group.
The not-equal syntax [attribute!="value"] is jQuery’s way to express that exclusion. Unlike standard CSS attribute operators, this selector is a jQuery extension available since version 1.0. Official docs note it is equivalent to :not([attr="value"]) in behavior.
Concept
Understanding the Not-Equal Selector
Think of a checklist. The selector asks: “Is this attribute either missing, or set to something other than my value?” If yes, the element matches.
name="newsletter" + [name!="newsletter"] → no match.
no name attribute + [name!="newsletter"] → matches (attribute absent).
type="text" + [type!="hidden"] → matches.
💡
Beginner Tip
Elements without the attribute also match [attr!="value"]. If you only want elements that have the attribute but a different value, filter further or use .filter() with a custom test.
attribute — the HTML attribute name (name, type, value, etc.).
value — exact string to exclude (case-sensitive). Can be a valid identifier or a quoted string.
Return value
A jQuery object containing elements without the attribute or with a different value.
Empty collection only when every candidate has the excluded value.
Official jQuery API example
jQuery
$( "input[name!='newsletter']" ).next().append( "<b>; not newsletter</b>" );
// Matches: no name attribute, name="accept"
// Skips: name="newsletter"
Cheat Sheet
⚡ Quick Reference
Element
[name!="newsletter"]
name="newsletter"
No match
name="accept"
Matches
no name attribute
Matches
name="Newsletter"
Matches (case differs)
name="newsletter_extra"
Matches (not exact value)
Compare
📋 [attr!="x"] vs [attr="x"]
Equals includes only exact matches; not-equal excludes one value and includes missing attributes.
Not !=
[name!="newsletter"]
Exclude one value
Exact =
[name="newsletter"]
Include one value
.not()
.not("[name='x']")
Faster alternative
Extension
!= jQuery only
Not native CSS
Hands-On
Examples Gallery
Example 1 follows the official jQuery API demo. Examples 2–5 cover missing-attribute behavior, comparison with equals, non-text inputs, and the recommended .not() pattern. Use the Try-it links to run each snippet.
📚 Official jQuery Demo
Append text to spans next to inputs whose name is not newsletter.
Example 1 — Official Demo: input[name!='newsletter']
Official jQuery demo — find inputs that do not have name="newsletter" and append bold text to the next sibling span.
jQuery
$( "input[name!='newsletter']" ).next().append( "<b>; not newsletter</b>" );
// Matches: no name, name="accept"
// Skips: name="newsletter"
Missing attributes match not-equal — a surprise for beginners who expect only “different values” to match. Plan for that when styling or validating form groups.
📈 Practical Patterns
Operator comparison, input types, and performance-friendly alternatives.
Example 3 — != vs = on the Same Input
See how equals and not-equal behave on one element.
name: accept
='newsletter': false
!='newsletter': true
Not-equal is the inverse of equals for elements that have a different value
How It Works
For elements with the attribute set, != is the logical opposite of =. The difference appears when the attribute is missing entirely — only != matches those nodes.
Example 4 — Style Non-Text Inputs with input[type!='text']
Highlight every input whose type is not exactly text.
checkbox, submit, button → class "special-input"
text inputs → unchanged
How It Works
Excluding one common type is often simpler than listing every other type. Scope to a form container when the page has many inputs.
Example 5 — Faster Pattern: $("input").not("[name='newsletter']")
Official jQuery recommendation — use CSS plus .not() for better performance in modern browsers.
jQuery
// Same result as input[name!='newsletter'], often faster:
$( "input" ).not( "[name='newsletter']" ).addClass( "other-field" );
// jQuery runs querySelectorAll("input") natively, then filters
All inputs except name="newsletter" → class "other-field"
Same selection as [name!='newsletter']
How It Works
Because [name!="value"] is not standard CSS, jQuery cannot delegate the whole query to native querySelectorAll. Splitting into a CSS selector plus .not() is the documented performance tip.
Applications
🚀 Common Use Cases
Exclude one field — input[name!='newsletter'] for non-newsletter radios.
Non-text inputs — input[type!='text'] to style special controls.
Skip hidden fields — input[type!='hidden'] before serializing a form.
Links not blank — a[target!='_blank'] for same-tab navigation styling.
Options except default — option[value!=''] to ignore placeholder options.
Data roles — [data-status!='archived'] to show active items only.
🧠 How jQuery Evaluates [attr!="value"]
1
Check attribute
Read whether the attribute exists on the candidate element.
DOM
2
Missing = match
If the attribute is absent, the element matches not-equal.
Include
3
Compare value
If present, match when the value is not exactly the excluded string.
Exclude
4
≠
Return collection
Matching elements become a jQuery object for chaining.
Important
📝 Notes
Available since jQuery 1.0 — jQuery extension, not standard CSS.
Equivalent in intent to :not([attr="value"]) per official docs.
Elements without the attribute also match — plan accordingly.
Comparison is case-sensitive, same as [attr="value"].
For performance, prefer $("css").not("[attr='value']") over [attr!="value"].
The attribute not-equal selector is a jQuery extension in 1.0+. It works wherever jQuery runs, but it is not valid in native querySelectorAll. Official docs recommend .not("[attr='value']") on a CSS selector for better performance in modern browsers.
✓ jQuery 1.0+ · Extension
jQuery [attribute!="value"]
Supported in all browsers that run your jQuery build. Not available outside jQuery — use .not() with standard CSS selectors when you need native query speed.
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
[attr!="value"]jQuery only
Bottom line: Not standard CSS. Prefer $("input").not("[name='newsletter']") for the same result with native selector optimization on the first pass.
Wrap Up
Conclusion
The attribute not-equal selector [name!="value"] excludes elements with one exact attribute value — and also matches elements where the attribute is missing. jQuery’s official demo, $("input[name!='newsletter']").next().append("<b>; not newsletter</b>"), shows the pattern on radio inputs.
Remember it is a jQuery extension, not native CSS. When performance matters, use $("your-css-selector").not("[attr='value']") instead. Pair with form IDs or classes to keep queries readable on large pages.
Use .not("[name='newsletter']") for better performance
Remember missing attributes also match !=
Scope: $("#form input[type!='hidden']")
Quote values with spaces or special characters
Pair with element type to narrow the search first
❌ Don’t
Assume != works in native querySelectorAll
Forget that elements without the attribute match too
Use bare $("[name!='x']") on huge DOM trees without scoping
Expect case-insensitive matching
Confuse != with “contains something else” substring logic
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about [attr!="value"]
Exclude one exact value — missing attributes count too.
5
Core concepts
≠01
!= syntax
Exclude value
API
∅02
Missing
Also matches
Rule
jQ03
Extension
Not CSS
Note
.not04
Faster
Use .not()
Perf
news05
Official
name!=newsletter
Demo
❓ Frequently Asked Questions
It selects elements that either do not have the specified attribute, or have that attribute with a value that is not exactly equal to the given string. For example, [name!="newsletter"] matches inputs with no name attribute and inputs where name is accept — but not name="newsletter".
No. It is a jQuery extension added in version 1.0. It is equivalent to :not([attr="value"]) in intent, but it is not part of the CSS specification and cannot use native querySelectorAll optimizations.
Yes. That is an important difference from mentally inverting [attr="value"]. An input with no name attribute matches [name!="newsletter"] because it does not have name="newsletter".
Use a CSS selector plus .not(): $("input").not("[name='newsletter']"). This lets jQuery use native querySelectorAll for the first pass, then filter out matches.
Yes. Comparison follows the same case-sensitive rules as [attr="value"]. name="Newsletter" does not equal newsletter and would match [name!="newsletter"].
[name="newsletter"] matches only elements whose name is exactly newsletter. [name!="newsletter"] matches everything else — including elements with no name attribute and elements where name is any other value.
Did you know?
jQuery added several attribute operators beyond CSS — including [attr!="value"]. Standard CSS has =, ~=, |=, ^=, $=, and *=, but not !=. For exclusion in native CSS, use :not([attr="value"]) inside a valid selector list.