.parent([selector]) (since jQuery 1.0) returns the immediate parent of each matched element — one level up. Optional selector keeps the parent only if it matches. Returns a new jQuery set; does not change the DOM.
Remember
$("li.item-a").parent(); // wrapping ul
$("p").parent(".selected"); // parent only if .selected
$(this).parent(); // common in click handlers
// parent() → one level up (direct parent)
// parents() → all ancestors
// closest() → nearest match (incl. self)
// children() → one level down
Select a child, then step up one level to its wrapper.
Select the child element(s) — e.g. $("li.item-a").
Call .parent() to get each one’s immediate parent.
Or pass a selector: .parent(".selected") to filter.
Chain methods on the new set (.append(), .addClass(), …).
If the parent fails the filter, the result is empty for that start — no further climb.
Piece
Required?
Role
Matched set
Yes
Child element(s)
selector
No
Keep parent only if it matches
Depth
—
Always exactly one level up
Return value
—
New jQuery set (0 or 1 per start, after unique)
Pseudocode
Pseudocode
call $(children).parent(selector?)
result = empty set
for each child in the matched set:
p = child.parentElement
if p is null:
skip
else if no selector OR p matches selector:
add p to result
return unique parents as a new jQuery object
(never climbs to grandparents)
Reference
Cheat Sheet
Keep these upward methods side by side.
Topic
Detail
Syntax
.parent([selector])
Since
jQuery 1.0
Depth
One level up only
vs .parents()
All ancestors
vs .closest()
Nearest match; tests self first
$("html").parent()
Contains document (API note)
DOM change?
No — query only
Try it
Live Preview
From li.item-a, compare .parent(), .parents("ul"), and .closest("ul").
I
II
A
B
C
III
parent → level-2 ul only. parents("ul") → level-2 and outer list.
Result
Ready — choose a call and click Run.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Parent of Item “A”
Official idea: from li.item-a, mark the wrapping ul.
Click Save → its .btn-group shows [active]
Toolbar itself is not selected (grandparent)
How It Works
Delegate. Listen for clicks on buttons inside the toolbar.
Clear. Remove previous marks.
Parent.$(this).parent() is the wrapping group.
Mark. Only that one-level parent is tagged.
Edge Cases & Pitfalls
Common surprises when the parent “isn’t there.”
filter
Failed selector → empty, not grandparent
.parent(".x") does not keep climbing. Use .closest(".x") or .parents(".x").
html
$("html").parent() is special
Official docs: it returns a set containing document, while $("html").parents() is empty.
unique
Shared parents are unique’d
Several siblings → one parent in the result set, not duplicates.
closest
Need self-or-ancestor?
.parent() never matches the start element. Prefer .closest().
detached
Detached nodes may have no parent
Elements not in the document can return an empty parent set.
Compatibility
Browser Support
.parent() has been part of jQuery since 1.0. It works in every browser that runs your loaded jQuery version — no separate browser feature flag.
✓ Stable · jQuery 1.0+
jQuery .parent()
Supported across jQuery 1.x, 2.x, and 3.x. Prefer a current jQuery 3.x build. Traversal uses the live DOM tree.
100%With jQuery
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
.parent()Universal
Bottom line: The simplest upward step. Use .parents() / .closest() when you need more than one level.
Analysis
Performance Notes
Approach
Cost
Best for
.parent()
Cheapest upward
Known direct wrapper
.closest(sel)
Stops at first match
Unknown depth / self match
.parents()
Walks to root
Collecting every ancestor
Prefer .parent() when the structure is fixed — one hop is enough.
Remember
Key Takeaways
Role: immediate parent — one level up — since jQuery 1.0.
Filter: optional selector; no match → empty, not climb.
vs parents / closest: one hop vs many / nearest match.
Mirror:.children() is the one-level-down counterpart.
One line:.parent() is a single step up to the element that wraps you.
Frequently Asked Questions
.parent() returns the immediate parent element of each node in the current collection — one level up the DOM tree. An optional selector filters the parent so it is included only when it matches.
.parent() moves up exactly one level — the direct parent only. .parents() collects every ancestor up to the document root. From a nested li, .parent() gives the containing ul; .parents("ul") can return multiple ul ancestors.
.parent() returns only the immediate parent — no further. .closest(selector) walks up from the element itself (including self) until the first selector match. Use .parent() for the direct parent; use .closest() when the match may be higher or include self.
.parent() goes up one level; .children() goes down one level. They are mirror methods — parent is who wraps you; children are what you directly wrap.
With .parent(selector), the immediate parent is tested. If it does not match, that start contributes nothing — jQuery does not walk to grandparents. Use .parents(selector) or .closest(selector) for a higher ancestor.
No. Like other jQuery traversing methods, it only queries the existing DOM and returns a new collection.