.unwrap()
methodThe .unwrap()
method in jQuery is used to remove the parents of all matched elements from the DOM.
.unwrap()
method Syntax.unwrap([selector])
selector
is used to determine whether to upwrap the element,If an element's parent does not match the selector, the element won't be unwrapped.
.unwrap()
method ExampleUnwrap the div around the paragraphs
HTML
<div class="container"> <p>Learn JavaScript</p> <p>Learn jQuery</p> Lautturi tutorial </div>
jQuery
$("p").unwrap();
Result
<p>Learn JavaScript</p> <p>Learn jQuery</p> Lautturi tutorial