六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 29|回复: 0

jquery 控制 wrapInner( html )

[复制链接]

升级  67.33%

130

主题

130

主题

130

主题

举人

Rank: 3Rank: 3

积分
402
 楼主| 发表于 2013-2-7 15:10:12 | 显示全部楼层 |阅读模式
wrapInner( 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").wrapInner("<b></b>");  });  </script>  <style>p { background:#bbf; }</style></head><body>  <p>Hello</p>  <p>cruel</p>  <p>World</p></body></html> 
$("p").wrapInner("<b></b>");
将‘<b></b>’封装在匹配p元素中每一个p元素内容上
 
 
wrapInner( 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").wrapInner(document.createElement("b"));  });  </script>  <style>p { background:#9f9; }</style></head><body>  <p>Hello</p>  <p>cruel</p>  <p>World</p></body></html> 
$("p").wrapInner(document.createElement("b"));
将特殊元素b匹配在匹配p元素集合每一个p元素的内容上
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表