English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery unwrap() Method

jQuery HTML/CSS Methods

The unwrap() method removes the parent element of the selected element.

Usagewrap()The method wraps the specified HTML element around the selected element.

Syntax:

$.unwrap(selector)

Example

Remove all paragraphs' parent elements:

$("button").click(function(){
  $("p").unwrap();
});
Test and See‹/›

Toggle between wrapping and expanding elements:

$("#btn1").click(function(){
  $("p").wrap("<div></div>");
});
$("#btn2").click(function(){
  $("p").unwrap();
});
Test and See‹/›

jQuery HTML/CSS Methods