This article mainly introduces the usage of the unwrap() method in jQuery. It analyzes the definition and function of the unwrap() method and the usage skills of removing the parent element of the matching element. Friends who need it can refer to it. Next
The example in this article describes the usage of the unwrap() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:
This method will remove the parent element of the matching element.
From the literal meaning of the method, we can see that it is the effect of clearing the wrap() method.
Syntax:
The code is as follows:
$(selector).unwrap()
Example code:
The code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="http://www.jb51.net/" /> < head > <title>脚本之家</title> <style type="text/css"> p { width :200px; height :200px; border:1px solid blue; } p { width:150px; height:150px; border:1px solid red; } </style> <script type="text/ javascript " src="jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $( document ).ready(function(){ $("button").click(function(){ $("p").unwrap(); }); }); </script> </head> <body> <p> <p>我是p元素</p> </p> <button>用p包裹每个段落</button> </body> </html>
The above code can remove the parent element of the p element.
The above is the detailed content of Example of usage of unwrap() method in jQuery. For more information, please follow other related articles on the PHP Chinese website!