How to get the current top-level node of the document

Node.prototype.ownerDocument

While it is not met, but later is unable to obtain direct document node may occur, then you can get to it by any node.

document.scripts[0].ownerDocument === document;
// true

document.ownerDocument;
// null

 

Guess you like

Origin www.cnblogs.com/aisowe/p/11504557.html