DocumentFragment.querySelectorAll()
DocumentFragment.queryselectorall() 方法返回NodeList中的元素DocumentFragment(使用文档节点的深度优先顺序遍历) 匹配指定的选择器组。
如果参数中指定的选择器无效,则会引发一个带 SYNTAX_ERR 值的DOMException。
备注: 这个 API 的定义被移动到ParentNode接口。
语法
elementList = documentframgment.querySelectorAll(selectors);
参数
- selectors
-
是一个
DOMString包含一个或多个用逗号分隔的 CSS 选择器。
示例
此示例返回 DocumentFragment 中所有 div 元素的列表,其中包含一个类“note”或“alert”:
js
var matches = documentfrag.querySelectorAll("div.note, div.alert");
规范
| Specification |
|---|
| DOM Standard # ref-for-dom-parentnode-queryselectorall① |
浏览器兼容性
BCD tables only load in the browser
参阅
- 它所属的
DocumentFragment接口。