jQuery Tutorial Tutorials - jQuery .unwrap() method

jQuery .unwrap() method

The .unwrap() method in jQuery is used to remove the parents of all matched elements from the DOM.

jQuery .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.

jQuery .unwrap() method Example

Unwrap 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

Try now

Date:2019-08-25 10:51:02 From:www.Lautturi.com author:Lautturi