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