Node
Node 是一个接口,许多 DOM API 对象的类型会从这个接口继承。它允许我们使用相似的方式对待这些不同类型的对象;比如, 继承同一组方法,或者用同样的方式测试。
以下接口都从 Node 继承其方法和属性:
Document, Element, Attr, CharacterData (which Text, Comment, and CDATASection inherit), ProcessingInstruction, DocumentFragment, DocumentType, Notation, Entity, EntityReference
在方法和属性不相关的特定情况下,这些接口可能返回 null。它们可能会抛出异常 - 例如,当将子节点添加到不允许子节点存在的节点时。
属性
从父类型 EventTarget 继承属性。
Node.baseURI 只读
返回一个表示base URL的DOMString。不同语言中的base URL的概念都不一样。 在HTML中,base URL表示协议和域名,以及一直到最后一个'/'之前的文件目录。
Node.baseURIObject
(不适用于网页内容) 只读的 nsIURI 对象表示元素的base URI.
Node.childNodes 只读
返回一个包含了该节点所有子节点的实时的 NodeList。NodeList 是“实时的”意思是,如果该节点的子节点发生了变化,NodeList对象就会自动更新。
Node.firstChild 只读
返回该节点的第一个子节点Node,如果该节点没有子节点则返回null。