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 July 2015.
Node.ownerDocument 只读属性会返回当前节点的顶层的 document 对象。
语法
document = node.ownerDocument
document
是当前元素的document
对象,其是当前元素的祖先。
例子
// 得到 p 元素所在文档的 HTML 节点 d = p.ownerDocument; html = d.documentElement;
注意
被此属性返回的 document
对象是在实际的 HTML 文档中的所有子节点所属的主对象。如果在文档节点自身上使用此属性,则结果是 null
。
规范
Specification |
---|
DOM # ref-for-dom-node-ownerdocument① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
ownerDocument |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.
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.