看图说话:
- 首先Dom是一套用来是
js
来操控·html
的一个接口; - 我们常用的
document
对象是继承于HTMLDoucment.prototype
,而HTMLDocument.prototype
是继承于Document.prototype
中的。。 - 了解这些,可以进一步了解,为什么
div.getElementById
不可以使用,却可以使用div.getElementsByClassName
div.getElementsByTagName
这是因为div是从属于Element的,getElementsByClassName,getElementsByTagName是定义与Document.prototype,和Element.prototype中的,所以div
和document
都可以使用,而getElementById是定义于Document.prototype
中的。。。