The attribute contains selector matches elements whose attribute value includes a given substring anywhere — start, middle, or end. Available since jQuery 1.0 (standard CSS3).
Remember
$("[attribute*='value']")
$("input[name*='man']")
✓ name="man"
✓ name="human"
✓ name="woman"
✗ name="person" (no "man" substring)
*= ≠ ~= // ~= needs a whole space-separated word
*= ≠ ^= // ^= is start only
Name the attribute, pick a substring, then query — optionally scoped to a tag.
Choose the attribute (name, href, data-id, …).
Write $("[attr*='substring']") — or with a tag: $("input[name*='man']").
Expect matches at any position inside the attribute string.
If you need a whole word in a space list, switch to ~= instead.
Piece
Required?
Role
attribute
Yes
Attribute name to search
value
Yes
Substring that must appear somewhere
Quotes around value
Recommended
Required for many values; identifiers may omit them
Pseudocode
Pseudocode
attrName = given attribute
substring = given value
matches = empty list
for each element with attrName:
v = element.getAttribute(attrName)
if v contains substring: // anywhere
add element
return jQuery(matches)
Reference
Cheat Sheet
Keep these facts handy while matching attribute substrings.
Topic
Detail
Syntax
$("[attr*='value']")
Matches
Substring anywhere in the attribute
Classic use
$("input[name*='man']")
vs ~=
~= = whole word in a space list
vs ^= / $=
Start only / end only
vs =
= is exact equality
Since
jQuery 1.0 (CSS3)
Try it
Live Preview
Run substring / word / starts-with selectors against sample inputs and see which name values match.
Sample markup mirrors the official jQuery name*='man' demo, plus a space-list trap.
man, human, woman
(each matched input value becomes "has man in it!")
How It Works
Limit to inputs. The input tag keeps the search on form controls.
Apply *=. Any name that contains man matches.
Set values..val() updates every match in one call.
List names. Mapping this.name shows which controls were selected.
Example 2 — *= vs ~=
See why a space-separated list behaves differently for substring vs whole-word matching.
jQuery
console.log("*= :", $("input[name*='man']").length);
console.log("~= :", $("input[name~='man']").length);
// *= matches "human", "woman", and "milk man"
// ~= matches only names where "man" is a whole word ("man", "milk man")
Any element. Omitting a tag searches every node with data-id.
Shared fragment.user matches at the start, middle, or alone.
Skip unrelated. Values without that substring are ignored.
Tip. Prefer a stricter operator if the fragment appears in unwanted places.
Example 5 — Case Sensitivity
Attribute value matching is case-sensitive — casing must align.
jQuery
console.log("man :", $("input[name*='man']").length);
console.log("Man :", $("input[name*='Man']").length);
// name="Man" matches only the second query
man : 2
Man : 1
Lowercase "man" does not match name="Man"
How It Works
Same letters, different case. Selectors compare the string as written.
Lowercase query. Matches lowercase name values that contain man.
Capitalized query. Matches only values that contain Man.
Habit. Keep attribute values and selectors in a consistent casing style.
Edge Cases & Pitfalls
Check these before relying on *= in real projects.
broad
Over-matching is easy
[name*="man"] also hits human and woman. Prefer ~=, ^=, or $= when you need stricter rules.
word
*= ≠ ~=
For space-separated lists (class-like tokens), ~= matches whole words only. Official docs call ~= more appropriate in many cases.
case
Case-sensitive values
In HTML, [name*="man"] does not match name="Man". Align casing in markup and selectors.
empty
Empty substring is a trap
[attr*=""] can match every element that has that attribute. Avoid empty search strings.
Compatibility
Browser Support
The attribute contains selector [attr*="value"] is part of CSS3 and has worked in jQuery since 1.0. Modern browsers implement it in native querySelectorAll.
✓ CSS3 · jQuery 1.0+
jQuery [name*="value"]
Supported in all modern browsers. Native: document.querySelectorAll("input[name*='man']"). Most generous attribute value matcher.
100%Standard CSS selector
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
*= combinatorUniversal
Bottom line: Safe everywhere jQuery runs. Use for flexible substring matches; switch to ~= when you need a whole word in a space-separated list.
Analysis
Performance Notes
Approach
Cost
Best for
$("input[name*='man']")
Native-friendly CSS
Scoped form controls
$("[data-id*='user']")
Wider scan
Any element with that data attr
$("[class*='btn']")
Often too broad
Prefer .btn or ~=
Attribute selectors are standard CSS, so jQuery can often use the browser engine. Narrow with a tag or a container on large pages, and avoid *= on class when a real class selector would do.
Remember
Key Takeaways
Role: match if the attribute value contains a substring anywhere.
Classic use:$("input[name*='man']") from the official demo.
Not ~=: for whole words in space lists, prefer ~=.
Standard CSS: works in jQuery 1.0+ and native querySelectorAll.
One line: use [attr*="value"] for flexible substring matches — and tighten with ~= when you need a whole word.
Frequently Asked Questions
It selects every element whose named attribute value contains the given substring anywhere — start, middle, or end. For example, [name*="man"] matches name="human", name="woman", and name="man".
Yes. Among jQuery attribute selectors that compare against a value, *= is the most generous — the substring can appear at any position inside the attribute string.
[attr*="man"] matches if "man" appears anywhere in the value. [attr~="man"] matches only when "man" is a whole space-separated word. For class-like lists, ~= is often more precise.
Yes. The attribute contains selector has worked in jQuery since 1.0 and is part of standard CSS3 attribute selectors supported by modern browsers.
In HTML documents, attribute selector matching is generally case-sensitive for attribute values. name="Man" does not match [name*="man"] unless the casing aligns.
Yes. The official demo uses $("input[name*=\"man\"]") to target only input elements whose name attribute contains the substring man.