KAXU 发表于 2013-2-7 18:36:42

jquery 控制 wrapAll( html )

wrapAll( html )
将‘html’的内容封装在匹配元素集合的整个集合上。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                     "http://www.w3.org/TR/html4/loose.dtd"><html><head><script src="http://code.jquery.com/jquery-latest.js"></script>    <script>$(document).ready(function(){    $("p").wrapAll("<div></div>");});</script><style>div { border: 2px solid blue; }p { background:yellow; margin:4px; }</style></head><body><p>Hello</p><p>cruel</p><p>World</p></body></html> 
$("p").wrapAll("<div></div>");
将‘<div></div>’封装在匹配p元素集合上
 
 
wrapAll( elem )
将特殊元素‘elem’封装在匹配元素集合的整个集合上
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                     "http://www.w3.org/TR/html4/loose.dtd"><html><head><script src="http://code.jquery.com/jquery-latest.js"></script>    <script>$(document).ready(function(){    $("p").wrapAll(document.createElement("div"));});</script><style>div { border: 2px solid blue; }p { background:yellow; margin:4px; }</style></head><body><p>Hello</p><p>cruel</p><p>World</p></body></html> 
$("p").wrapAll(document.createElement("div"));
将div元素封装在匹配p元素集合上 
页: [1]
查看完整版本: jquery 控制 wrapAll( html )