上图来自于《JavaScript权威指南(第六版)》P375

受到上图的启发,写了如下测试代码:

 var head = document.getElementsByTagName("head");
console.log(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(head[0]))))); // Node对象 console.log(Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(document)))); // Node对象

沿着上图的文档节点层次结构,上面的代码输出都为Node对象。

那么问题来了,上篇博文引自《Professional JavaScript for Web Developers》中的那段话:

In browser, the document object is an instance of HTMLDocument (which inherits from Document) and presents the entire HTML page.

1. The document object presents the entire 要怎么解释呢?(document.getElementById());

2. Document对象和Element对象在DOM中各扮演了什么角色?(新增了哪些自己的(非继承的)属性和方法?)

部分解答这个问题: (《高程》P354)

  • The Document type represents an entire document and is the root node of a hierarchy. In javaScript, the document object allows for querying and retrieval of nodes in a number of different ways.
  • An Element node represents all HTML or XML elements in a document and can be used to manipulate their contents and attributes.

因此我们认为,首先通过Document方法找到某个节点(宏观),然后再通过手术刀式地对元素节点进行内容和属性上的操作(微观)。

最新文章

  1. Swift -Login(MVC 纯代码)
  2. Linux下搭建coreseek(sphinx+mmseg3)全文检索
  3. Highcharts 在低版本 IE 上使用注意事项及个人总结
  4. The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,reflectorFactory?,plugins?,environments?,databaseIdProv
  5. jQuery选择器之动态列表显示Demo
  6. 10、Android数据存储
  7. Median of Two Sorted Arrays(Java)
  8. USB OTG介绍(转载)
  9. 如何安装一个优秀的BUG管理平台(转)
  10. myeclipse将java项目转换成web项目,导出war包
  11. 数据结构课程设计四则运算表达式求值(C语言版)
  12. GDAL库调试(包括跨语言调试)
  13. 二十三、Interpreter 解释器模式
  14. jsp(web作业)
  15. 微信web开发者工具 移动调试
  16. 【经典】5种IO模型 | IO多路复用
  17. 转载-对js中new、prototype的理解
  18. [洛谷3375]【模板】KMP字符串匹配
  19. 外卖ERP管理系统(二)
  20. 疯狂Java学习笔记(75)-----------NIO.2第一篇

热门文章

  1. MySQL 将数据文件分布到不同的磁盘
  2. Promise中有多个resove
  3. docker下安装运行mysql的过程以mysql5.7为例
  4. JavaScript关系运算符
  5. join on 和group
  6. CTS添加新测试用例步骤
  7. 阿sa
  8. fastjson =< 1.2.47 反序列化漏洞浅析
  9. 线程系列3--Java线程同步通信技术
  10. 协程系列之Event Loops