jQuery unwrap()

The jQuery unwrap() method removes the parent element of the selected elements. Syntax: $(selector).unwrap() Example1: <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script> <script> $(document).ready(function(){ $(“#btn1”).click(function(){ $(“p”).wrap(“<em></em>”); }); $(“#btn2”).click(function(){ $(“p”).unwrap(); }); }); </script> </head> <body> <p>Hello!</p> <p>Nice to see you.</p> <button id=”btn1″>Wrap</button> <button id=”btn2″>Unwrap</button> </body> </html> Example2: <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script> <script> $(document).ready(function(){ $(“#btn1”).click(function(){ $(“p”).wrapAll(“<div></div>”); … Read more