<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>根节点ownerDocument</title> <!-- 所有document子节点都可以使用ele.ownerDocument;方法获取document节点 --> </head> <body> <div> <main> <nav> </nav> </main> </div> <script> var nav=document.getElementsByTagName("nav")[0];//获取nav console.log(nav.ownerDocument);//#document </script> </body> </html>
来源:https://www.cnblogs.com/vinson-blog/p/12112731.html