<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        jquery選擇器:last與:last-child兩者的區(qū)別

        來源:懂視網(wǎng) 責編:小采 時間:2020-11-27 20:19:03
        文檔

        jquery選擇器:last與:last-child兩者的區(qū)別

        jquery選擇器:last與:last-child兩者的區(qū)別:今天寫$("ul li:last-child").offset().top發(fā)現(xiàn)報錯,而$("ul li").last().offset().top就沒錯了。原因在于:這兩個選擇器都是匹配集合中的最后一個元素,差別在于 :last 將匹配所有的集合中的最后一個元素。而 :last-ch
        推薦度:
        導讀jquery選擇器:last與:last-child兩者的區(qū)別:今天寫$("ul li:last-child").offset().top發(fā)現(xiàn)報錯,而$("ul li").last().offset().top就沒錯了。原因在于:這兩個選擇器都是匹配集合中的最后一個元素,差別在于 :last 將匹配所有的集合中的最后一個元素。而 :last-ch

        今天寫$("ul li:last-child").offset().top發(fā)現(xiàn)報錯,而$("ul li").last().offset().top就沒錯了。原因在于:
        這兩個選擇器都是匹配集合中的最后一個元素,差別在于 :last 將匹配所有的集合中的最后一個元素。而 :last-child 將匹配集合中的所有位置為最后一個的子元素。:last 將永遠返回一個元素,而 :last-child可能返回一批元素。
        原來如此啊!

        :last Selects the last matched element.
        Note that :last selects a single element by filtering the current jQuery collection and matching the last element within it.
        Additional Notes:
        Because :last is a jQuery extension and not part of the CSS specification, queries using 
        :last cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. 
        To achieve the best performance when using :last to select elements, first select the elements using a pure CSS selector, then use.filter(":last").

        :last-child:

        Selects all elements that are the last child of their parent.

        <div>
        <span>John,</span>
        <span>Karl,</span>
        <span>Brandon,</span>
        <span>Sam</span>
        </div>
        <div>
        <span>Glen,</span>
        <span>Tane,</span>
         
        <span>Ralph,</span>
        <span>David</span>
        </div>
        <script>
        $("div span:last-child")
        .css({color:"red", fontSize:"80%"})
        .hover(function () {
        $(this).addClass("solast");
        }, function () {
        $(this).removeClass("solast");
        });

        這兩個選擇器都是匹配集合中的最后一個元素,差別在于 :last 將匹配所有的集合中的最后一個元素。而 :last-child 將匹配集合中的所有位置為最后一個的子元素。:last 將永遠返回一個元素,而 :last-child可能返回一批元素。

        $('div p:last') 選擇最后一個P元素并高亮顯示得出結(jié)果如下:

        <div>
        <p>Paragraph</p>
        <p>Paragraph</p>
        <p>Paragraph</p>
        </div>
        <div>
        <p>Paragraph</p>
        <p>Paragraph</p>
        <p>Paragraph</p>
        </div>
        <div>
        <p>Paragraph</p>
        <p>Paragraph</p>
        <p>Paragraph</p>
        </div>

        $('div p:last-child') 將選擇所有位于div最后一個p子元素,并高亮:

        <div>
        <p>Paragraph</p>
        <p>Paragraph</p>
        <p>Paragraph</p>
        </div>
        <div>
        <p>Paragraph</p>
        <p>Paragraph</p>
        <p>Paragraph</p>
        </div>
        <div>
        <p>Paragraph</p>
        <p>Paragraph</p>
        <p>Paragraph</p>
        </div>

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        jquery選擇器:last與:last-child兩者的區(qū)別

        jquery選擇器:last與:last-child兩者的區(qū)別:今天寫$("ul li:last-child").offset().top發(fā)現(xiàn)報錯,而$("ul li").last().offset().top就沒錯了。原因在于:這兩個選擇器都是匹配集合中的最后一個元素,差別在于 :last 將匹配所有的集合中的最后一個元素。而 :last-ch
        推薦度:
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 成人毛片18女人毛片免费96 | 亚洲精品视频在线免费| 亚洲大香人伊一本线| 久香草视频在线观看免费 | 亚洲w码欧洲s码免费| 免费在线观看中文字幕| 亚洲色成人网一二三区| 免费无码又爽又黄又刺激网站| 2020因为爱你带字幕免费观看全集 | 国产亚洲精品精华液| 国产精品亚洲专区在线播放| 16女性下面无遮挡免费| 亚洲成人福利在线观看| 成人无遮挡毛片免费看| 亚洲国产av玩弄放荡人妇| 免费视频爱爱太爽了| 亚洲最大的成人网| 97国产免费全部免费观看| 亚洲成AV人片在线观看WWW| 老司机午夜性生免费福利| 毛片A级毛片免费播放| 亚洲av永久无码精品秋霞电影秋| 国产免费不卡v片在线观看| 亚洲国产成人私人影院| sihu国产精品永久免费| 亚洲AⅤ永久无码精品AA| 亚洲av永久无码一区二区三区| 亚洲成A人片在线观看中文| 久久水蜜桃亚洲AV无码精品| 国产啪亚洲国产精品无码 | 久久久精品国产亚洲成人满18免费网站 | 精品少妇人妻AV免费久久洗澡| 亚洲国产成人无码av在线播放| 91香蕉国产线观看免费全集| 久久亚洲国产视频| 国产一级片免费看| 亚洲第一福利网站| 天天看免费高清影视| 亚洲成av人无码亚洲成av人| 亚洲最大av无码网址| 国产免费久久久久久无码|