Mat*_*ens 5 html javascript xpath dom
选择所有元素,文本节点和注释节点的XPath表达式的顺序与它们在文档中出现的顺序相同?
以下有效选择所有元素,但不选择文本节点和注释节点:
var result = document.evaluate('//*', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null),
index = -1;
while (++index < result.snapshotLength) {
console.log(result.snapshotItem(index));
}
Run Code Online (Sandbox Code Playgroud)
有可能做以下事情吗?(注意:这是非功能性伪代码.)
document.evaluate('//* and text() and comment()');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2361 次 |
| 最近记录: |