.selector was a String on a jQuery collection: the CSS selector passed to jQuery() when the set was created. Example: $("div.item").selector → "div.item". It was never reliable after traversal (.find(), .eq(), …). Prefer keeping your own selector variable or the official plugin parameter pattern.
Remember
// jQuery 1.x / 2.x only
$("div.item").selector // "div.item"
// After traversal — do not trust it to re-query the same set
$("div.item").eq(0).selector // still "div.item", but length is 1
// jQuery 3.x
$("div.item").selector // undefined (removed)
// Modern plugin pattern (official)
$.fn.foo = function (selector, options) { /* … */ };
$("div.bar").foo("div.bar", { dog: "bark" });
Only for understanding older code or Migrate warnings — not for new features.
Build a set with a selector string: $("div.item").
In jQuery 1.x/2.x, read $set.selector.
Do not re-query with that string after .eq(), .filter(), or .add().
In plugins, accept selector as a method argument instead.
In jQuery 3.x, expect undefined — keep your own variable.
Piece
Required?
Role
Selector string in $()
Yes (to populate)
What .selector stored
jQuery 1.3–2.x
Yes (to read it)
Property exists only there
Explicit plugin arg
Yes (modern)
Official replacement
Traversal chains
—
Make .selector unreliable
Pseudocode
Pseudocode
set = jQuery("div.item")
// legacy: set.selector == "div.item"
set2 = set.eq(0)
// length is 1, but selector may still be "div.item"
// re-running that string would match ALL items — stale!
// modern plugin:
plugin(collection, selector, options)
// use the passed selector — do not read collection.selector
Reference
Cheat Sheet
Keep these facts handy while reading legacy collections.
Topic
Detail
Type
Property → String
Added
jQuery 1.3
Deprecated
jQuery 1.7
Removed
jQuery 3.0
Meaning
Selector passed to jQuery() at creation
Replacement
Pass selector as a plugin parameter
Try it
Live Preview
Toggle between jQuery 1.12 (property exists) and the modern pattern note. Source: jQuery API.
Legacy
Uses jQuery 1.12.4 so .selector still exists. In 3.x it is undefined.
Log
Click “Read .selector”.
One
Two
Practice
jQuery Examples
Examples 1–4 use jQuery 1.12.4. Example 5 uses jQuery 3.7.1 (modern pattern).
Example 1 — Read the Original String
Inspect .selector after a simple CSS selection (jQuery 1.12).
Plugin got selector: div.bar
.selector in 3.x: undefined (removed)
How It Works
API. Plugin requires selector as argument 1.
Call site. Repeat "div.bar" explicitly.
Filter. Use the passed string — not collection metadata.
3.x..selector is gone; this pattern still works.
Edge Cases & Pitfalls
Watch for these when reading legacy selector metadata.
3.0
Gone in jQuery 3
.selector is undefined. Do not build new features on it.
stale
Unreliable after traversal
.eq(), .filter(), .add(), and friends change the set without a trustworthy rebuild string.
empty
DOM / HTML wrappers
$(element) or $("<div>") often yields an empty selector string.
plugin
Ask for the string
Official fix: $.fn.foo = function(selector, options) { … } and repeat the selector at the call site.
Compatibility
Browser Support
.selector existed on collections in jQuery 1.3–2.x. It was deprecated in 1.7 and removed in jQuery 3.0. Not available in modern jQuery releases.
✓ Deprecated · Removed 3.0
.selector
Historical collection metadata only. Use jQuery 1.12.x / 2.2.x for legacy demos. New code should pass selector strings explicitly.
N/AModern support
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
.selectorRemoved
Bottom line: Do not use in new projects. Migrate plugins to an explicit selector parameter. Keep studying it to understand older codebases and Migrate warnings.
Analysis
Performance Notes
Approach
Cost
Best for
Read .selector (1.x/2.x)
Free
Legacy debugging only
Re-query with stale string
Wrong results
Avoid
Explicit plugin selector arg
Free
Modern plugins
Own variable for the query
Free
Widgets and modules
The cost is correctness, not CPU. Storing your own selector string (or accepting it as a parameter) is clearer and works in jQuery 3.
Remember
Key Takeaways
Role: original selector string at collection creation.
Unreliable: traversal can make it a bad rebuild key.
Removed: deprecated 1.7, gone in jQuery 3.0.
Replace: pass the selector as a plugin argument.
One line:.selector remembered creation-time query text — do not use it in jQuery 3; pass selectors explicitly.
Frequently Asked Questions
.selector is a String on jQuery collections (1.3–2.x) that stored the CSS selector passed to jQuery() when the set was first created — for example $("div.item").selector returns "div.item".
No. Official docs warn it was never reliable after traversal. Methods like .find(), .eq(), .filter(), and .add() change the set without guaranteeing a selector that would rebuild the same set.
No. It was deprecated in jQuery 1.7 and removed in jQuery 3.0 along with .context. Pass the selector string explicitly into plugins instead.
Often an empty string. When you pass a DOM node, HTML string, or callback — not a selector — jQuery had nothing to store.
.selector held the query string ("#menu li"). .context held the DOM root that limited the search. Both were creation-time metadata removed in jQuery 3.0.
Require the selector as a parameter: $.fn.foo = function(selector, options) { ... }; then call $("div.bar").foo("div.bar", { dog: "bark" }); — repeat the selector explicitly.