The DOM node originally passed to jQuery() as the search root. If none was passed, it is usually the document. Added in jQuery 1.3. It is a property — not a method — so write $("li").context, not $("li").context().
Remember
$("ul").context // usually document
$("ul", document.body).context // BODY element
// Second arg still scopes the search in jQuery 3.x
// Reading .context back only works on 1.x / 2.x
Pass an optional root into jQuery(), then (on 1.x / 2.x) read it back from the collection.
Optionally pass a DOM node as the second argument: $(sel, root).
jQuery searches only inside that root (or the document if omitted).
On jQuery 1.x / 2.x, read .context — a native Element or Document.
In jQuery 3.x, keep the root variable yourself — do not read .context.
For events, bind with .on() on a stable parent instead of removed .live().
Piece
Required?
Role
Selector
Yes
What to match
Second arg (context)
Optional
Search root; defaults to document
.context
Legacy
Stored root on the collection (removed 3.0)
Return type
—
Native DOM Element or Document
Pseudocode
Pseudocode
root = optional DOM node (or document)
set = jQuery(selector, root)
→ search only inside root
→ (jQuery 1.x / 2.x) set.context = root
// Modern (jQuery 3.x):
root = document.getElementById("panel")
set = $(selector, root) // scoping still works
keep root in your variable // do not read .context
// Events:
$(root).on("click", ".child", handler)
Reference
Cheat Sheet
Keep these facts handy when reading legacy collections.
Click any .item — including ones added later.
Selected: Post 2
How It Works
Root. Bind on #feed — that parent is your context.
Filter. The ".item" selector matches clicked descendants.
Dynamic. Items added later still work because events bubble to #feed.
No metadata. You never need .context or removed .live().
Edge Cases & Pitfalls
Watch for these when reading or migrating .context.
removed
Undefined in jQuery 3.x
.context does not exist on modern collections. Keep your own container variable.
merge
.add() does not update context
The property still reflects the original set’s root after merges.
type
Native DOM node
Use .nodeName / === — not jQuery methods on .context.
events
Not the same as this
Inside a handler, this is the event target element — not the collection’s search root.
Compatibility
Browser Support
.context existed on jQuery 1.3–2.x collections. It was removed in jQuery 3.0. The scoped constructor form jQuery(selector, context) remains supported.
✓ Removed · jQuery 3.0
.context
Available on jQuery 1.12.x and 2.2.x only. jQuery 3.x has no .context — use an explicit element reference and .on() delegation.
LegacyjQuery 1.x / 2.x
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
.contextRemoved 3.0
Bottom line: Scoped selection with the second jQuery() argument is still valid. Reading .context back from the collection is what was removed — keep the container variable yourself.
Analysis
Performance Notes
Approach
Cost
Best for
Read .context
Free
Legacy debugging (1.x / 2.x)
$(sel, root)
Cheaper search
Widget-scoped selectors
Global $(sel)
Can be costly
Avoid on large documents when a root exists
The property itself was cheap metadata. Real savings come from scoping selectors with a second argument so jQuery searches a smaller subtree.
Remember
Key Takeaways
Role: DOM node — the search root for that collection.
Default: usually document when no second arg.
Status: removed in jQuery 3.0 — keep your own root variable.
Modern: scope with $(sel, root); delegate with .on().
One line:.context stored the search root — today you keep that root yourself and still pass it as the second argument.
Frequently Asked Questions
.context is a read-only property on a jQuery collection (1.3–2.x). It holds the DOM node that was passed as the second argument to jQuery() when the set was created. If none was supplied, it is usually the document.
After selecting elements, access collection.context — it is a native DOM Element or Document, not a jQuery object. Example: var root = $(".item", container).context; console.log(root.id).
No. .context was deprecated in jQuery 1.10 / 2.0 and removed in jQuery 3.0. Use jQuery 1.12.x or 2.2.x for legacy demos, or keep an explicit element reference instead of reading .context.
You pass the search root into jQuery(selector, context) to limit the search. On jQuery 1.x/2.x, that node was also stored on the collection as .context. The second argument still works in jQuery 3.x — only reading .context back was removed.
Usually not. .context reflects the original creation context of that set. Elements merged later with .add() may come from a different root; the property does not track each member individually.
Keep a variable pointing to the container you care about, pass it to jQuery() as the second argument when needed, and bind delegated events with .on(events, selector, handler) on a stable parent.