<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                子元素篩選選擇器不常使用,其篩選規則比起其它的選擇器稍微要復雜點 子元素篩選選擇器描述表: ![](https://box.kancloud.cn/2016-03-20_56ee4c19016d2.png) 注意事項: :first只匹配一個單獨的元素,但是:first-child選擇器可以匹配多個:即為每個父級元素匹配第一個子元素。這相當于:nth-child(1) :last 只匹配一個單獨的元素, :last-child 選擇器可以匹配多個元素:即,為每個父級元素匹配最后一個子元素 如果子元素只有一個的話,:first-child與:last-child是同一個 :only-child匹配某個元素是父元素中唯一的子元素,就是說當前子元素是父元素中唯一的元素,則匹配 jQuery實現:nth-child(n)是嚴格來自CSS規范,所以n值是“索引”,也就是說,從1開始計數,:nth-child(index)從1開始的,而eq(index)是從0開始的 nth-child(n) 與 :nth-last-child(n) 的區別前者是從前往后計算,后者從后往前計算 ~~~ <!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title></title> <link rel="stylesheet" href="imooc.css" type="text/css"> <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> </head> <body> <h2>子元素篩選選擇器</h2> <h3>:first-child、:last-child、:only-child</h3> <div class="left first-div"> <div class="div"> <a>:first-child</a> <a>第二個元素</a> <a>:last-child</a> </div> <div class="div"> <a>:first-child</a> </div> <div class="div"> <a>:first-child</a> <a>第二個元素</a> <a>:last-child</a> </div> </div> <script type="text/javascript"> //查找所有class="first-div"下的a元素,只取第一個 //針對所有父級下的第一個 $('.first-div a:first-child').css("color", "#CD00CD"); </script> <script type="text/javascript"> //查找所有class="first-div"下的a元素,只取最后一個 //針對所有父級下的最后一個 //如果只有一個元素的話,last也是第一個元素 $('.first-div a:last-child').css("color", "red"); </script> <script type="text/javascript"> //查找所有class="first-div"下的a元素,如果只有一個子元素的情況 $('.first-div a:only-child').css("color", "blue"); </script> <h3>:nth-child、:nth-last-child</h3> <div class="left last-div"> <div class="div"> <a>:first-child</a> <a>第二個元素</a> <a>第三個元素</a> <a>:last-child</a> </div> <div class="div"> <a>:first-child</a> <a>第二個元素</a> </div> <div class="div"> <a>:first-child</a> <a>第二個元素</a> <a>第三個元素</a> <a>:last-child</a> </div> </div> <script type="text/javascript"> //查找所有class="last-div"下的a元素,選擇第二個 $('.last-div a:nth-child(2)').css("color", "#CD00CD"); </script> <script type="text/javascript"> //查找所有class="last-div"下的a元素,選擇第倒數第二個 $('.last-div a:nth-last-child(2)').css("color", "red"); </script> </body> </html> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看