.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.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$(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)
Call
What it does
jQuery set
Elements whose parent will be removed
selector
Unwrap only if parent matches
Return
Same matched set (chainable)
Since
1.4; selector in 3.0
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select the elements whose parent should go: $("p"), $(".item").
Step 2
Call .unwrap() with no args, or pass a selector (jQuery 3.0+) to filter parents.
Step 3
Confirm the parent is gone — matched elements (and siblings) stay in the tree.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
Match.#a sits in div.box — selector matches → unwrap.
Miss.#b sits in section — selector fails → stay wrapped.
Safe. Use a selector when only some wrappers should be removed.
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.