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