DocumentFragment.querySelectorAll() 方法返回 NodeList of elements within the DocumentFragment (using depth-first pre-order traversal of the document's nodes) that matches the specified group of selectors.

If the selectors specified in parameter are invalid a DOMException 采用 SYNTAX_ERR value is raised.

注意: The definition of this API was moved to the ParentNode 接口。

句法

elementList = documentfragment.querySelectorAll(selectors);
					

参数

selectors
DOMString containing one or more CSS selectors separated by commas.

范例

This example returns a list of all div elements within the DocumentFragment with a class of either " note " or " alert ":

var matches = documentfrag.querySelectorAll("div.note, div.alert");
					

规范

规范 状态 注释
Selectors API Level 1
The definition of 'DocumentFragment.querySelectorAll' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
querySelectorAll Chrome 1 Edge 12 Firefox 3.5 IE 9 Opera 10 Safari 3.2 WebView Android Yes Chrome Android Yes Firefox Android 4 Opera Android 10.1 Safari iOS 3.2 Samsung Internet Android Yes

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: