此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Node:ownerDocument 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

Node 接口的只读属性 ownerDocument 会返回该节点所属的顶层 document 对象。

一个 Document,是所有子节点都在其中创建的顶层对象。

如果在文档节点自身上使用此属性,则值为 null

示例

js
// 给定一个节点 "p",获取文档对象的顶级 HTML 子元素

const d = p.ownerDocument;
const html = d.documentElement;

规范

Specification
DOM
# ref-for-dom-node-ownerdocument①

浏览器兼容性