29. Element ownerDocument 属性

来源:互联网 发布:jersey接收json 编辑:程序博客网 时间:2024/05/13 18:56

实例

返回元素的 ownerDocument:

document.getElementById("demo").ownerDocument;
<!DOCTYPE html><html><body><p id="demo">请点击按钮来获得 <p> 元素的 ownerDocument 的节点类型。</p><button onclick="myFunction()">试一下</button><script>function myFunction(){var x=document.getElementById("demo");  x.innerHTML=x.ownerDocument.nodeType;}</script></body></html>

定义和用法

ownerDocument 属性以 Document 对象的形式返回节点的 owner document。

在 HTML 中,HTML 文档本身始终是元素的 ownerDocument。

请在我们的文档对象参考手册中浏览更多有关 Document 对象的内容。


这里写图片描述

0 0
原创粉丝点击