jQuery Attribute Equals [name="value"]

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Exact match

What You’ll Learn

The attribute equals selector — written [name="value"] — matches elements whose attribute value is exactly equal to your search string. Matching is case-sensitive. It is the foundation of attribute selectors — ideal for type, name, and fixed option values — available since jQuery 1.0.

01

Syntax

[attr="x"]

02

Exact

Full value

03

Case

Sensitive

04

Official

value='Hot Fuzz'

05

vs *=

Whole not part

06

Since 1.0

CSS + jQuery

Introduction

Before prefix, suffix, or substring operators, there is the simplest attribute rule: exact equality. When you know the full attribute value — a button type, a field name, a country code in an option — the equals selector is the clearest choice.

The syntax [attribute="value"] checks whether the attribute string equals your search text with no extra characters before or after. jQuery has supported this selector since version 1.0, and browsers implement it natively through standard CSS attribute selectors.

Understanding the Equals Selector

Think of the attribute value as a label on a box. The selector asks: “Is this label exactly my text — nothing more, nothing less?” If yes, the element matches.

  • value="Hot Fuzz" + [value="Hot Fuzz"] → matches.
  • value="Hot Fuzz 2" + [value="Hot Fuzz"] → no match (extra characters).
  • type="submit" + [type="submit"] → matches.
  • type="button" + [type="submit"] → no match.
💡
Beginner Tip

If the value might appear as part of a longer string, use [attr*="value"] instead. Equals is strict — use it when you know the complete attribute value.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( "[attribute='value']" )
// shorthand:
$( "[attribute='value']" )

// common patterns:
$( "input[value='Hot Fuzz']" )
$( "input[type='submit']" )

Parameters

  • attribute — the HTML attribute name (name, value, type, etc.).
  • value — exact string the attribute value must equal (case-sensitive). Can be a valid identifier or a quoted string.

Return value

  • A jQuery object containing every element whose attribute equals the value.
  • Empty collection when no values match.

Official jQuery API example

jQuery
$( "input[value='Hot Fuzz']" ).next().text( "Hot Fuzz" );

// Matches only value="Hot Fuzz"
// Does NOT match value="Hot Fuzz 2" or value="hot fuzz"

⚡ Quick Reference

value attribute[value="Hot Fuzz"]
Hot FuzzMatches
Hot Fuzz 2No match
hot fuzzNo match (case differs)
Hot Fuzz!No match (extra character)
HotNo match (partial value)
Cold FuzzNo match (leading space)

📋 [attr="x"] vs [attr*="x"] and other operators

Equals checks the whole value; other operators check position or tokens.

Exact =
[type="submit"]

Full value only

Contains *
[href*="pdf"]

Substring anywhere

Starts ^
[href^="https"]

Prefix at start

Ends $
[href$=".pdf"]

Suffix at end

Examples Gallery

Example 1 follows the official jQuery API demo. Examples 2–5 cover exact-match rules, operator comparison, submit buttons, and scoped form fields. Use the Try-it links to run each snippet.

📚 Official jQuery Demo

Update the next sibling span for inputs whose value is exactly Hot Fuzz.

Example 1 — Official Demo: input[value='Hot Fuzz']

Official jQuery demo — find inputs with value exactly Hot Fuzz and set the text of the next sibling span.

jQuery
$( "input[value='Hot Fuzz']" ).next().text( "Hot Fuzz" );

// Matches: value="Hot Fuzz"
// Skips: value="Cold Fuzz", value="Hot Fuzz 2", value="hot fuzz"
Try It Yourself

How It Works

jQuery compares the entire value string to Hot Fuzz. Even one extra character or different casing breaks the match — that is what makes equals precise.

Example 2 — Test Exact Matching with .is()

Programmatically verify which value strings equal Hot Fuzz.

jQuery
var values = [ "Hot Fuzz", "Hot Fuzz 2", "hot fuzz", "Cold Fuzz", "Hot" ];

values.forEach( function( v ) {
  var $el = $( "<input>" ).attr( "value", v ).appendTo( "body" );
  console.log( v, "→", $el.is( "[value='Hot Fuzz']" ) ? "MATCH" : "no" );
  $el.remove();
});
Try It Yourself

How It Works

Hot Fuzz 2 contains the same words but is not an exact match — a common beginner mistake that *= would partially match but = correctly rejects.

📈 Practical Patterns

Operator comparison, button types, and scoped queries.

Example 3 — = vs *= on the Same Value

See how exact and substring operators differ on one attribute.

jQuery
var val = "Hot Fuzz 2";
var $input = $( "<input>" ).attr( "value", val ).appendTo( "body" );

console.log( "value:", val );
console.log( "='Hot Fuzz':", $input.is( "[value='Hot Fuzz']" ) );
console.log( "*='Hot Fuzz':", $input.is( "[value*='Hot Fuzz']" ) );

$input.remove();
Try It Yourself

How It Works

Choose = when you know the complete value. Choose *= when any substring match is acceptable.

Example 4 — Target Submit Buttons with input[type='submit']

Disable every submit button on the page using an exact type match.

jQuery
$( "input[type='submit']" ).prop( "disabled", true );

// Matches type="submit" exactly
// Does not match type="button" or type="reset"
Try It Yourself

How It Works

HTML input types are fixed tokens — perfect for exact matching. This pattern is clearer than filtering by tag alone when mixed button types share the page.

Example 5 — Scoped Field #login-form input[name='username']

Highlight the username field inside one form by exact name match.

jQuery
$( "#login-form input[name='username']" ).addClass( "highlight" );

// Matches name="username" inside #login-form
// Ignores username_confirm or fields in other forms
Try It Yourself

How It Works

Pair exact name matching with a form ID so you target one field without affecting similarly named inputs elsewhere on the page.

🚀 Common Use Cases

  • Input typesinput[type='submit'], input[type='checkbox'].
  • Field namesinput[name='email'], textarea[name='message'].
  • Option valuesoption[value='us'] for country dropdowns.
  • Data attributes[data-role='admin'] when the value is a fixed token.
  • Link targetsa[target='_blank'] for external links.
  • Radio groupsinput[type='radio'][name='size'][value='large'].

🧠 How jQuery Evaluates [attr="value"]

1

Read attribute

Get the full string value from each candidate element.

DOM
2

Compare exactly

Check whether the value equals the search string — case-sensitive, full length.

Exact
3

No partial match

Extra characters before or after the string fail the match.

Strict
4

Return collection

Matching elements become a jQuery object for chaining.

📝 Notes

  • Available since jQuery 1.0 — standard CSS attribute selector.
  • Comparison is case-sensitive (per official jQuery docs).
  • The entire attribute value must match — whitespace counts.
  • Not the same as *= — substring anywhere vs full value only.
  • Quote values with spaces: [value='Hot Fuzz'].
  • Pair with element type and ID for performance: #form input[name='email'].

Browser Support

The attribute equals selector is part of CSS and works in jQuery 1.0+. Evergreen browsers support it in native querySelectorAll. IE7+ supports attribute selectors with jQuery fallbacks where needed.

CSS · jQuery 1.0+

jQuery [attribute="value"]

Supported in all modern browsers. Native: document.querySelectorAll("input[type='submit']"). Case-sensitive matching applies everywhere.

100% Standard CSS selector
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
[attr="value"] Universal

Bottom line: Ideal for fixed tokens like input types and field names. Use *= when the value may be part of a longer string.

Conclusion

The attribute equals selector [name="value"] matches when an attribute value is exactly your search string — case-sensitive and complete. jQuery’s official demo, $("input[value='Hot Fuzz']").next().text("Hot Fuzz"), shows how precise matching works on form values.

Use = for known full values like type="submit"; use *=, ^=, or $= when you need substring or positional matching instead. Scope selectors to keep queries fast and readable on large pages.

💡 Best Practices

✅ Do

  • Use input[type='submit'] for exact type matching
  • Quote values with spaces: [value='Hot Fuzz']
  • Scope: $("#form input[name='email']")
  • Remember case sensitivity in HTML attributes
  • Choose = when you know the complete value

❌ Don’t

  • Expect Hot Fuzz 2 to match [value="Hot Fuzz"]
  • Use = when *= is what you really need
  • Forget leading or trailing spaces in attribute values
  • Assume hot fuzz matches ="Hot Fuzz"
  • Omit quotes around values that contain spaces or special characters

Key Takeaways

Knowledge Unlocked

Five things to remember about [attr="value"]

Exact match of the full attribute value.

5
Core concepts
Aa 02

Case

Sensitive

Rule
type 03

Submit

Common use

Pattern
≠ * 04

Not *=

Full string

Compare
Hot 05

Official

Hot Fuzz demo

Demo

❓ Frequently Asked Questions

It selects elements whose named attribute value is exactly equal to the given string — character for character. For example, [value="Hot Fuzz"] matches only value="Hot Fuzz", not value="Hot Fuzz 2" or value="hot fuzz".
Yes. jQuery and CSS attribute selectors use case-sensitive comparison for attribute values in HTML documents. value="hot fuzz" does not match [value="Hot Fuzz"] because the casing differs.
[attr="pdf"] matches only when the entire value is exactly pdf. [attr*="pdf"] matches pdf anywhere inside the value. [attr^="pdf"] matches values starting with pdf. [attr$="pdf"] matches values ending with pdf.
Yes. The attribute equals selector is standard CSS and has worked in jQuery since 1.0, with native querySelectorAll support in modern browsers.
Yes. input[type="submit"] is one of the most common exact-match patterns — it targets inputs whose type attribute is exactly submit.
No. The entire attribute value must match exactly. Use [value*="Hot Fuzz"] if you need substring matching anywhere in the value.
Did you know?

CSS attribute selectors form a family: = exact, ~= word, |= prefix, ^= starts-with, $= ends-with, and *= contains. The equals operator is the strictest — use it when you know the complete attribute value.

Continue to Attribute Not Equal Selector

After exact matching, learn how to exclude one attribute value with [name!="value"].

Attribute not-equal tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful