TreeWalker.previousNode() method moves the current 节点 to the previous visible node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists,or if it is before that the root node defined at the object construction, returns null and the current node is not changed.

句法

node = treeWalker.previousNode();
					

范例

var treeWalker = document.createTreeWalker(
    document.body,
    NodeFilter.SHOW_ELEMENT,
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
    false
);
var node = treeWalker.previousNode(); // returns null as there is no parent
					

规范

规范 状态 注释
DOM
The definition of 'TreeWalker.previousNode' in that specification.
实时标准 无变化自 Document Object Model (DOM) Level 2 Traversal and Range Specification
Document Object Model (DOM) Level 2 Traversal and Range Specification
The definition of 'TreeWalker.previousNode' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table on 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
previousNode Chrome 1 Edge 12 Firefox 4 IE 9 Opera 9 Safari 3 WebView Android 3 Chrome Android Yes Firefox Android 4 Opera Android 10.1 Safari iOS 3 Samsung Internet Android Yes

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: