---
title: "Why are use the unwrap method in JQ?"  
description: "Why are use the unwrap method in JQ?"  
author: "Ethan Karla"  
published: 2021-07-28  
canonical: https://answers.mindstick.com/qa/93822/why-are-use-the-unwrap-method-in-jq  
category: "web application"  
tags: ["web development", "web application development"]  
reading_time: 2 minutes  

---

# Why are use the unwrap method in JQ?

Why are use the [unwrap method](https://www.mindstick.com/forum/158785/what-is-the-purpose-of-the-unwrap-method-in-rust-s-result-type) in JQ?

## Answers

### Answer by Ravi Vishwakarma

jQuery unwrap() is used to unwrap the selected HTML element from parent tag.

```
Syntax:$(selector).unwrap()    unwarp the parent tag
```

```
Example <!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title></title>
    <script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script>
    <script type='text/javascript'>
        $(document).ready(function () {
            $('#btn1').click(function () {
                var content = '<div> </div>'
                $('p').wrap(content);
                $('p').text('wrap with div tag and style');
            });
            $('#btn2').click(function () {
                var content = '<div></div>'
                $('p').unwrap();
                $('p').text('unwrap with div and style');
            });
        });
    </script>
    <style>
        body {
            margin: 10px;
            padding: 10px;
        }
        div {
            background-color: red;
            color: white;
            text-align: center;
            font-size:20px;
            height:100px;
            line-height:80px;
        }
    </style>
</head>
<body>
    <button id='btn1'>Click me for wrap the data</button>
    <button id='btn2'>Click me for unwrap p tag form div tag</button>
    <p>default stage in p tag</p>
</body>
</html>
```

Output

![Why are use the unwrap method in JQ?](https://answers.mindstick.com/questionanswer/b79e2d13-4c2e-47de-b4c1-6607e0f1a744/images/e2000db0-42ee-4e34-b16c-496ea93308cd.png)

\


---

Original Source: https://answers.mindstick.com/qa/93822/why-are-use-the-unwrap-method-in-jq

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
