jQuery Attribute Equals [name="value"]

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

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).

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("[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
CallWhat it does
See the examples below.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Choose the attribute (value, type, name, …).
Step 2Write $("[attr='exact']") — or with a tag: $("input[value='Hot Fuzz']").
Step 3Quote values with spaces or special characters.

Return Value

Return ValueDescription
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

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.

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.

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.

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: Attribute Not Equal Selector

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

Attribute Not Equal Selector tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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