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().
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("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
Call
What it does
Selector
What to match
Second arg (context)
Search root; defaults to document
.context
Stored root on the collection (removed 3.0)
Return type
Native DOM Element or Document
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
context
Used in Second arg (context). Search root; defaults to document
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — Official: Default vs Body Context
Append lines showing .context as a string and as nodeName.
Global.$("button") searches the whole document → two matches.
Scoped.$("button", main) searches only inside #main → one match.
Roots differ. Global .context is the document; scoped .context is #main.
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.