Node: ownerDocument 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

Node 介面的只讀 ownerDocument 屬性返回節點的頂級文件物件。

一個 Document,它是建立所有子節點的頂級物件。

如果此屬性用於節點本身是文件的情況,則值為 null

示例

js
// Given a node "p", get the top-level HTML
// child of the document object

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

規範

規範
DOM
# ref-for-dom-node-ownerdocument①

瀏覽器相容性