<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("li").wrap("<div></div>");
});
</script>
</head>
<body><ul>
<li title='苹果'>苹果</li>
<li title='橘子'>橘子</li>
<li title='菠萝'>菠萝</li>
</ul>
</body>
</html>
上面如果是 wrap,结果是:
<ul>
<div><li title="苹果">苹果</li></div>
<div><li title="橘子">橘子</li></div>
<div><li title="菠萝">菠萝</li></div>
</ul>
如果是wrapAll,结果是:
<ul>
<div><li title="苹果">苹果</li><li title="橘子">橘子</li><li title="菠萝">菠萝</li></div>
</ul>
原帖地址:http://tianjun309.iteye.com/blog/803183