久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 querySelectorAll().方法返回的結(jié)果是否有序?

Using querySelectorAll(). Is the result returned by the method ordered?(使用 querySelectorAll().方法返回的結(jié)果是否有序?)
本文介紹了使用 querySelectorAll().方法返回的結(jié)果是否有序?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試制作一個(gè)適用于多個(gè)頁(yè)面的 js 代碼.我正在嘗試使用 querySelectorAll() 從 DOM 中獲取元素.

I'm trying to make a js code that works with multiple pages. I'm trying to use querySelectorAll() to obtain the elements form the DOM.

我需要訂購(gòu)元素.為此,我可以使用 xPath 或選擇器(我更喜歡使用選擇器,但 xPath 也可以).問(wèn)題是:
querySelectorAll() 返回的 NodeList 中的元素是否按照標(biāo)簽在 HTML 中出現(xiàn)的順序排列?

I need the elements to be ordered. In order to do that I may use xPath or selectors (I'd prefer to use selectors but xPath is also ok). The problem is:
Are the elements in the NodeList returned by querySelectorAll() ordered against the order that the tags appear in the HTML?

注意:我想添加標(biāo)簽:querySelectorAll

Note: I'd like to add the tag: querySelectorAll

推薦答案

返回的節(jié)點(diǎn)列表是有序的.快速測(cè)試證明了這一點(diǎn):

The returned node list is ordered. A quick test proved it:

document.querySelectorAll("body, head")[0]; //Returned [object HTMLHeadElement]

顯然,<head> 標(biāo)簽出現(xiàn)在 HTML 文檔中的 <body> 之前.NodeList 的第一個(gè)元素也是 <head> 元素,即使選擇器在 `head 之前顯示 body.

Obviously, the <head> tag appears before <body> in a HTML document. The first element of the NodeList is also a <head> element, even if the selector shows body before `head.

來(lái)自 http://www.w3.org/TR/selectors-api/#queryselectorall:

NodeSelector 接口上的 querySelectorAll() 方法必須,當(dāng)調(diào)用,返回一個(gè)包含所有匹配元素的 NodeList節(jié)點(diǎn)子樹中的節(jié)點(diǎn),按文檔順序.如果沒有此類節(jié)點(diǎn),該方法必須返回一個(gè)空的 NodeList.

The querySelectorAll() method on the NodeSelector interface must, when invoked, return a NodeList containing all of the matching Element nodes within the node’s subtrees, in document order. If there are no such nodes, the method must return an empty NodeList.

這篇關(guān)于使用 querySelectorAll().方法返回的結(jié)果是否有序?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

CSS selector when :target empty(:target 為空時(shí)的 CSS 選擇器)
Does the CSS direct decendant (gt;) not have any value in selectivity?(CSS 直接后代 (gt;) 在選擇性方面沒有任何價(jià)值嗎?)
Safari bug :first-child doesn#39;t update display:block when items are removed with JS(Safari 錯(cuò)誤:當(dāng)使用 JS 刪除項(xiàng)目時(shí),first-child 不更新 display:block)
nth-Child CSS selectors(nth-子 CSS 選擇器)
Using same ID for multiple HTML tags?(對(duì)多個(gè) HTML 標(biāo)簽使用相同的 ID?)
TestCafe - How to check if a web element exists or does not exist without failing the test?(TestCafe - 如何在不通過(guò)測(cè)試的情況下檢查 Web 元素是否存在?)
主站蜘蛛池模板: 久久亚洲综合 | 久久97精品| 少妇精品久久久久久久久久 | 国产一区二区三区免费 | 日韩中文字幕视频 | 人人干人人干人人干 | 亚洲一二三区免费 | 日韩二三区 | 国产69精品久久久久777 | 久久99精品久久久久久 | 9999久久 | 欧美成人免费电影 | 国产激情一区二区三区 | 99精品在线免费观看 | 最近最新中文字幕 | 国产精品成人久久久久a级 久久蜜桃av一区二区天堂 | 国产免费av在线 | 亚洲一区二区精品视频 | 亚洲精品日韩综合观看成人91 | 国产一级电影在线 | 欧美videosex性极品hd | 国产欧美一区二区三区在线看 | 黄色大片视频 | 羞羞色网站 | 亚洲精品一区二区二区 | 国产精品一区一区三区 | 91精品国产麻豆 | 亚洲精品一区二区 | 看片国产 | 一区二区三区四区视频 | 亚洲欧美日韩精品久久亚洲区 | 亚洲一区二区视频 | 91色视频在线观看 | 国产一二三区在线 | h视频在线观看免费 | 91精品一区二区三区久久久久久 | 日韩精品一区二区三区四区 | 一区视频| 国产午夜精品一区二区三区四区 | 狠狠干av| 中文字幕在线免费 |