jQuery unwrap() Method

The jQuery unwrap() method can be used to remove the parent of the selected element. If you unwrap the element for more than one time, it remove other parent elements too.

jQuery unwrap() Method

Syntax

The syntax of this method is given below:-

Syntax
$(selector).unwrap()

The method requires no parameter to pass and use the method.

Description of the Parameters

The description of these parameters is given below.

Parameter Name Description
selector Specify the element to select and remove the parent element to unwrap. You can use the element tag name, class name, or id to select. It is a required field.

jQuery unwrap() Method to Remove Parent Element

If you want to remove the parent element of the selected element, you have to use the jQuery unwrap() method as given below. It unwrap the selected element when you click the button element.

Example

Test it Live

The example contains the paragraph element inside the div element. The method removes the div element which is the parent of paragraph element.

You may also like to read

I hope you like this tutorial on jQuery unwrap() method. If you have any queries regarding the tutorial, please comment below.

References