为了账号安全,请及时绑定邮箱和手机立即绑定

div:first 是什么意思????

div:first 是什么意思????

Blizzard_lihe 2016-11-19 15:02:31
<!DOCTYPE html> <html> <head>     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />     <title></title>     <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>     <style>     .right div {         background: yellow;     }     </style> </head> <body>     <h2>replaceWith()和replaceAll()</h2>     <div class="left">         <button class="bt1">点击,通过replaceWith替换内容</button>         <button class="bt2">点击,通过rreplaceAll替换内容</button>     </div>     <div class="right">         <div>             <p>第一段</p>             <p>第二段</p>             <p>第三段</p>         </div>         <div>             <p>第四段</p>             <p>第五段</p>             <p>第六段</p>         </div>     </div>     <script type="text/javascript">     //只克隆节点     //不克隆事件     $(".bt1").on('click', function() {         //找到内容为第二段的p元素         //通过replaceWith删除并替换这个节点         $(".right > div:first p:eq(1)").replaceWith('<a style="color:red">replaceWith替换第二段的内容</a>')     })     </script>     <script type="text/javascript">     //找到内容为第六段的p元素     //通过replaceAll删除并替换这个节点     $(".bt2").on('click', function() {         $('<a style="color:red">replaceAll替换第六段的内容</a>').replaceAll('.right > div:last p:last');     })     </script> </body> </html>div:first 是什么意思????div:first 是什么意思????
查看完整描述

2 回答

已采纳
?
stone310

TA贡献361条经验 获得超191个赞

第一个div

查看完整回答
反对 回复 2016-11-19
?
慕粉2340472005

TA贡献1条经验 获得超0个赞

父节点.right 里面有两个DIV 节点  div:first 指的是父节点下的第一个div 子节点 也就是p标签里第一段到第三段

查看完整回答
反对 回复 2016-11-25
  • 2 回答
  • 0 关注
  • 1942 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信