.unwrap() removes the parent of each matched element and leaves those elements in the DOM where the parent was (since jQuery 1.4). It is the inverse of .wrap(). Returns the same jQuery set for chaining.
Remember
$(els).unwrap() // remove immediate parent
$(els).unwrap(".wrapper") // jQuery 3.0+ — only if parent matches
Before: <div><p>Hi</p></div>
After: <p>Hi</p>
siblings move up with the matched elements
≠ .remove() (remove deletes the matched els)
Select the inner elements, then unwrap their parents.
Select the elements whose parent should go: $("p"), $(".item").
Call .unwrap() with no args, or pass a selector (jQuery 3.0+) to filter parents.
Confirm the parent is gone — matched elements (and siblings) stay in the tree.
Chain further methods on the same selection if needed.
Piece
Required?
Role
jQuery set
Yes
Elements whose parent will be removed
selector
No (3.0+)
Unwrap only if parent matches
Return
—
Same matched set (chainable)
Since
—
1.4; selector in 3.0
Pseudocode
Pseudocode
unwrap(optionalSelector):
for each element in this set:
parent = element.parent
if optionalSelector and parent does not match:
skip
else:
move parent's children into parent's place
remove parent from the DOM
return this set
Reference
Cheat Sheet
Keep these facts handy when stripping wrappers.
Topic
Detail
Syntax
.unwrap([selector])
Removes
Immediate parent (not the matched els)
Keeps
Matched elements + their siblings
Inverse
.wrap()
Selector
jQuery 3.0+ only
Returns
Original matched set
Since
jQuery 1.4
Try it
Live Preview
Run unwrap on a small HTML sketch and watch the parent disappear.
Browser demo of .unwrap() — same ideas as the examples below.
Result
before → <div><p>Hi</p></div>
after → <p>Hi</p>
/* parent div removed */
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Works in Chrome, Firefox, Safari, and Edge when jQuery 1.4+ is loaded. Use 3.0+ for .unwrap(selector).
100%With jQuery 1.4+
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
.unwrap()Universal
Bottom line: Safe for modern jQuery. Prefer a selector (3.0+) when only specific parent wrappers should be removed.
Analysis
Performance Notes
Approach
Cost
Best for
.unwrap()
DOM move + remove parent
Strip one wrapper layer
.unwrap(sel)
Same + parent match test
Selective unwrap (3.0+)
Repeated unwrap in a loop
Cost × layers
Deep nested wrappers
Cost scales with how many parents you remove. Prefer one clear unwrap over many accidental calls in hot paths.
Remember
Key Takeaways
Role: remove the parent; keep the matched elements.
Inverse: pair with .wrap() to add / strip wrappers.
Selector: jQuery 3.0+ filters which parents to remove.
≠ remove: unwrap keeps children; remove deletes the selection.
One line:.unwrap() strips the parent wrapper and leaves the matched elements in place.
Frequently Asked Questions
.unwrap() removes the immediate parent of each matched element and leaves those elements (and their siblings) in place. It returns the same jQuery set for chaining. Available since jQuery 1.4; optional selector since 3.0.
.unwrap() deletes the parent wrapper and keeps the matched elements. .remove() deletes the matched elements themselves.
Yes. .wrap() adds a parent around matched elements; .unwrap() removes that parent and promotes the children.
Since jQuery 3.0, yes. .unwrap(".box") removes the parent only if it matches the selector. If the parent does not match, that element is not unwrapped. With no argument, the immediate parent is always removed.
All children of the removed parent — matched elements and siblings — are promoted together to replace the parent in the DOM.
The original jQuery collection of matched elements (not the removed parents), so you can keep chaining.