The attribute ends-with selector matches elements whose attribute value ends exactly with a given string (suffix). Available since jQuery 1.0 (standard CSS3).
Remember
$("[attribute$='value']")
$("input[name$='letter']")
✓ name="newsletter"
✓ name="loveletter"
✗ name="letterbox" (ends with "box")
✗ name="myLetter" (case differs)
$= ≠ ^= // ^= is start only
$= ≠ *= // *= is anywhere
Name the attribute, pick a suffix, then query — casing must match exactly.
Choose the attribute (name, href, id, …).
Write $("[attr$='suffix']") — or with a tag: $("input[name$='letter']").
Confirm the value truly ends with that string (not just contains it).
Watch case: .pdf and .PDF are different suffixes.
Piece
Required?
Role
attribute
Yes
Attribute name to test
value
Yes
Exact suffix the value must end with
Quotes around value
Recommended
Required for many values; identifiers may omit them
Pseudocode
Pseudocode
attrName = given attribute
suffix = given value
matches = empty list
for each element with attrName:
v = element.getAttribute(attrName)
if v ends with suffix: // case-sensitive
add element
return jQuery(matches)
Reference
Cheat Sheet
Keep these facts handy while matching attribute suffixes.
Topic
Detail
Syntax
$("[attr$='value']")
Matches
Value ending exactly with the suffix
Classic use
$("input[name$='letter']")
File links
$("a[href$='.pdf']")
Case
Sensitive (.pdf ≠ .PDF)
vs ^= / *=
Start only / anywhere
Since
jQuery 1.0 (CSS3)
Try it
Live Preview
Run ends-with / starts-with / contains selectors against sample inputs and see which name values match.
Sample markup mirrors the official jQuery name$='letter' demo, plus file-link examples.
main-panel, side-panel
(panel-main is skipped — suffix, not prefix)
How It Works
Any element. Omitting a tag searches every node with an id.
Shared ending. Both main-panel and side-panel end with -panel.
Order matters.panel-main fails because it ends with main.
Naming tip. Consistent ID suffixes make group selection easy.
Example 5 — Case Sensitivity
Official rule: the comparison is case sensitive — casing must align.
jQuery
console.log("letter :", $("input[name$='letter']").length);
console.log("Letter :", $("input[name$='Letter']").length);
// name="myLetter" matches only the second query
letter : 2
Letter : 1
Lowercase "letter" does not match name="myLetter"
How It Works
Same letters, different case. Selectors compare the suffix as written.
Lowercase query. Matches values ending in lowercase letter.
Capitalized query. Matches values ending in Letter.
Habit. Normalize file extensions and suffixes in markup when possible.
Edge Cases & Pitfalls
Check these before relying on $= in real projects.
case
Case-sensitive by design
Official docs state the comparison is case sensitive. .pdf and .PDF need separate selectors (or normalized URLs).
trap
Contains ≠ ends with
letterbox contains letter but fails $=. Use *= if the fragment can sit anywhere.
query
Query strings break file suffixes
file.pdf?v=2 does not end with .pdf. Strip query params first, or match a broader pattern.
empty
Empty suffix is a trap
[attr$=""] can match every element that has that attribute. Avoid empty search strings.
Compatibility
Browser Support
The attribute ends-with 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$='letter']"). Case-sensitive suffix matching.
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. Ideal for suffixes and file extensions — keep casing consistent in markup and selectors.
Analysis
Performance Notes
Approach
Cost
Best for
$("input[name$='letter']")
Native-friendly CSS
Scoped form controls
$("a[href$='.pdf']")
Native-friendly CSS
File-type link filters
$("[id$='-panel']")
Wider scan
Any element with that id suffix
Attribute selectors are standard CSS, so jQuery can often use the browser engine. Narrow with a tag or a container on large pages.
Remember
Key Takeaways
Role: match attributes whose value ends with an exact suffix.
Classic use:$("input[name$='letter']") from the official demo.
Case-sensitive:.pdf ≠ .PDF.
Not *=: ending with ≠ containing somewhere in the middle.
One line: use [attr$="value"] for exact, case-sensitive suffix matches — great for extensions and naming endings.
Frequently Asked Questions
It selects elements whose named attribute value ends exactly with the given string. For example, [name$="letter"] matches name="newsletter" and name="loveletter" because those values end with the suffix letter.
Yes. Per the official jQuery API, the comparison is case sensitive. name="myLetter" does not match [name$="letter"] because the casing differs at the end.
[attr$="pdf"] matches only when the value ends with pdf. [attr*="pdf"] matches pdf anywhere. [attr^="pdf"] matches values that start with pdf.
Yes. The attribute ends-with selector is standard CSS3 and has worked in jQuery since 1.0, with native querySelectorAll support in modern browsers.
Yes. a[href$=".pdf"] is a common pattern for URLs that end with the .pdf extension — remember case sensitivity (.PDF vs .pdf).
No. The value must end with the exact suffix letter. letterbox ends with box, not letter. Use [name*="letter"] if you need substring matching anywhere.