jQuery | unwrap() with Examples
The unwrap() method is an inbuilt method in jQuery which is used to remove the parent element from the selected element.
Syntax:
$(selector).unwrap()
Parameters: This method does not accept any parameter.
Return Value: This method returns the selected element with the changes made by unwrap() method.
Below example illustrates the unwrap() method in jQuery:
Example:
<!DOCTYPE html> <html> <head> <title>The unwrap Method</title> <script src= </script> <!-- jQuery code to show the working of this method --> <script> $(document).ready(function() { $("button").click(function() { $("p").unwrap(); }); }); </script> <style> div { width: 300px; height: 100px; background-color: lightgreen; padding: 20px; font-weight: bold; font-size: 20px; border: 2px solid green; } span { background-color: yellow; } </style> </head> <body> <div> <!-- click on this span element --> <p>Welcome to <span>GeeksforGeeks!.</span></p> <button>Click Here!</button> </div> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- jQuery | val() with Examples
- jQuery | after() with Examples
- jQuery | last() with Examples
- jQuery | has() with Examples
- jQuery | on() with Examples
- jQuery | eq() with Examples
- jQuery | one() with Examples
- jQuery | first() with Examples
- jQuery | click() with Examples
- jQuery | slice() with Examples
- jQuery | insertAfter() with Examples
- jQuery | mouseout() with Examples
- jQuery | index() with examples
- jQuery | hasClass() with Examples
- jQuery | serializeArray() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



