jQuery Attribute Equals [name="value"]

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is [name="value"]?

The attribute equals selector matches elements whose attribute value is exactly equal to a given string — character for character. Available since jQuery 1.0 (standard CSS).

Remember
$("[attribute='value']")

$("input[value='Hot Fuzz']")
  ✓ value="Hot Fuzz"
  ✗ value="Hot Fuzz 2"
  ✗ value="hot fuzz"     (case differs)

=  ≠  *=   // *= is substring anywhere
=  ≠  !=   // != excludes that exact value
UsePrefer
Exact value$("[attr='value']")
Exclude a value$("[attr!='value']")
Substring$("[attr*='value']")

How to Use [name="value"]

Name the attribute, set the exact value, then query — quote values that contain spaces.

  1. Choose the attribute (value, type, name, …).
  2. Write $("[attr='exact']") — or with a tag: $("input[value='Hot Fuzz']").
  3. Quote values with spaces or special characters.
  4. Remember: the whole value must match — not a prefix, suffix, or substring.
PieceRequired?Role
attributeYesAttribute name to test
valueYesExact string the attribute must equal
Quotes around valueRecommendedRequired when the value has spaces

Pseudocode

Pseudocode
attrName = given attribute
target   = given value
matches  = empty list

for each element with attrName:
    v = element.getAttribute(attrName)
    if v == target:                   // exact, case-sensitive
        add element

return jQuery(matches)

Cheat Sheet

Keep these facts handy while matching exact attribute values.

TopicDetail
Syntax$("[attr='value']")
MatchesEntire attribute value equals the string
Classic use$("input[value='Hot Fuzz']")
Common form$("input[type='submit']")
CaseSensitive in HTML attribute values
vs *= / !=Substring / exclude exact value
SincejQuery 1.0 (standard CSS)

Live Preview

Run equals / contains / type selectors against sample inputs and see which values match.

Sample markup mirrors the official jQuery value='Hot Fuzz' demo.

Result
$("input[value='Hot Fuzz']")
matched: 1
values: Hot Fuzz

/* exact value only */

jQuery Examples

Short, copy-ready snippets. Open a browser with jQuery loaded, or use Try It Yourself for a live editor.

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

Find the input with that exact value, then label its next sibling span.

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

console.log($("input[value='Hot Fuzz']").length);
// 1
Try It Yourself

How It Works

  1. Exact value. Only value="Hot Fuzz" matches — not longer strings.
  2. Move to sibling. .next() selects the span after that input.
  3. Set text. .text("Hot Fuzz") labels the match clearly.
  4. Official pattern. Same idea as the jQuery API demo.

Example 2 — = vs *=

See how exact equality differs from substring matching on the same inputs.

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

// = matches only the exact value
// *= also matches "Hot Fuzz 2"
Try It Yourself

How It Works

  1. Equals is strict. The whole attribute string must match.
  2. Star is loose. Any value containing Hot is kept.
  3. Compare counts. Lengths show how much wider *= is.
  4. Pick carefully. Known exact value → =. Partial text → *=.

Example 3 — Select input[type="submit"]

One of the most common exact-match patterns in forms.

jQuery
var label = $("input[type='submit']").val();
console.log(label);
console.log("count:", $("input[type='submit']").length);
Try It Yourself

How It Works

  1. Exact type. Only inputs whose type is submit match.
  2. Read the label. .val() returns the button’s displayed value.
  3. Count matches. Confirms how many submit controls were found.
  4. Form habit. Prefer this over looser filters when the type is known.

Example 4 — Match by Exact name

Select a specific form field by its name attribute.

jQuery
var v = $("input[name='email']").val();
console.log(v);
console.log("matched:", $("input[name='email']").length);
Try It Yourself

How It Works

  1. Target by name. [name='email'] finds that exact field name.
  2. Read the value. .val() returns the current input contents.
  3. One field. Exact equality keeps sibling fields with other names out.
  4. Practical use. Hook validation or submit logic to a known field name.

Example 5 — Case Sensitivity

Attribute value matching is case-sensitive — casing must align.

jQuery
console.log("Hot Fuzz:", $("input[value='Hot Fuzz']").length);
console.log("hot fuzz:", $("input[value='hot fuzz']").length);

// lowercase does not match value="Hot Fuzz"
Try It Yourself

How It Works

  1. Same letters, different case. Selectors compare the string as written.
  2. Title case query. Matches value="Hot Fuzz" only.
  3. Lowercase query. Matches value="hot fuzz" only.
  4. Habit. Keep attribute values and selectors in a consistent casing style.

Edge Cases & Pitfalls

Check these before relying on = in real projects.

exact

Extra characters break the match

value="Hot Fuzz 2" does not match [value="Hot Fuzz"]. Use *=, ^=, or $= for partial matches.

case

Case-sensitive values

In HTML, [value="Hot Fuzz"] does not match value="hot fuzz". Align casing in markup and selectors.

quotes

Quote values with spaces

Write [value='Hot Fuzz'], not bare tokens. Spaces need quotes in the selector string.

presence

Missing attribute never matches

An element without the attribute is skipped. To select “has attribute, any value,” use [attr].

Browser Support

The attribute equals selector [attr="value"] is standard CSS and has worked in jQuery since 1.0. Modern browsers implement it in native querySelectorAll.

✓ CSS · jQuery 1.0+

jQuery [name="value"]

Supported in all modern browsers. Native: document.querySelectorAll("input[value='Hot Fuzz']"). Exact, case-sensitive value matching.

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
= combinator Universal

Bottom line: Safe everywhere jQuery runs. Prefer exact = when the full value is known; switch to *= / ^= / $= for partial matches.

Performance Notes

ApproachCostBest for
$("input[type='submit']")Native-friendly CSSKnown exact attributes
$("input[value='Hot Fuzz']")Native-friendly CSSExact value lookups
$("[value*='Hot']")Wider / looserOnly when you need a substring

Exact attribute selectors are standard CSS, so jQuery can often use the browser engine. Narrow with a tag or a container on large pages.

Key Takeaways

  • Role: match when the attribute value equals a string exactly.
  • Classic use: $("input[value='Hot Fuzz']") from the official demo.
  • Not *=: exact equality ≠ substring match.
  • Quote spaces: use [value='Hot Fuzz'], not bare tokens.

One line: use [attr="value"] when you know the full attribute string and need an exact match.

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. In HTML documents, attribute selector matching is generally case-sensitive for values. value="hot fuzz" does not match [value="Hot Fuzz"].
[attr="pdf"] matches only when the entire value is exactly pdf. [attr*="pdf"] matches pdf anywhere. [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.

Next: [name!="value"]

Select elements that do not have a given exact attribute value.

!= selector 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.

9 people found this page helpful