DOM树

       

     document  HTMLDocument  Document的关系

     看如下操作:

  

  可见document的原型链上有HTMLDocument.prototype和Document.prototype

 

  1. document表示文档对象,而它的构造函数是HTMLDocument
  2. HTMLDocument.prototype.proto = Document.prototype
  3. 因此,document和Document之间的关系就是:
  4. document继承自HTMLDocument.prototype,而HTMLDocument.prototype又继承自Document.prototype
  5. head,body等标签直接继承自HTMLHeadElement.prototype,HTMLBodyElement.prototype等
  6. getElementById方法定义在Document.prototype上,即Element节点不能调用该方法。
  7. getElementByName方法定义在HTMLDocument.prototype上,即非document元素不能调用该方法。
  8. getElementsByTagName方法定义在Document.prototype和Element.prototype上
  9. HTMLDocument.prototype定义了一些常用的属性,body,head分别指代body,head标签
  10. document.body = ;
  11. document.head = ;
  12. Document.prototype上定义了documentElement属性,指代文档的根元素。
  13. document.documentElement =
  14. getElementsByClassName、querySelector、querySelectorAll在Document.prototype和 Element.prototype上均有定义。



 

posted @ 2019-06-17 17:16  啊啊啊于远文  阅读(155)  评论(0编辑  收藏  举报