此方法用於把全部匹配的元素的子元素(包括文本節點)使用指定的 HTML 元素來包裹javascript
將每個匹配的元素的子內容(包括文本節點)用一個HTML結構包裹起來css
htmlhtml
HTML標記代碼字符串,用於動態生成元素幷包裝目標元素java
elementjquery
用於包裝目標元素的DOM元素函數
fnui
生成包裹結構的一個函數this
實例:spa
<html lang='zh-cn'>
<head>
<title>Insert you title</title>
<meta http-equiv='description' content='this is my page'>
<meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type='text/javascript' src='./js/jquery-1.12.1.min.js'></script>
<style type="text/css">
*{margin:0;padding:0;} html{font:400 15px/1.2em 'Courier New';color:#666;width:750px;margin:25px auto;}
ul{list-style:none;} .hover{color:#FF96EC;} .wrapAll{color:#FF96EC;} </style>
<script type='text/javascript'> $(function(){ $('.list').wrapInner(document.createElement("div")); }); </script>
</head>
<body>
<div id='demo'>
<div class='noClassDemo'>
<ul class='list'>
<li>Index value :</li>
<li>Index value :</li>
<li>Index value :</li>
<li>Index value :</li>
<li>Index value :</li>
<li>Index value :</li>
<li class='active'>Index</li>
<li class='wrap'>Index value :</li>
<li>Index value :</li>
</ul>
<div>
<p class='list'>this is unwrap test</p>
</div>
</div>
<p class='list'>this is unwrap test</p>
</div>
</body>
</html>