nodeType是JavaScript中的一个HTML DOM属性。nodeType属性返回选定节点的节点类型,可以让我们知道、区分文档中的各个节点。
JavaScript中的所有节点类型都继承自Node类型,因此所有节点类型都共享相同的基本属性和方法。每个节点都有一个nodeType属性,用于表明节点的类型。
nodeType | 节点名称 |
---|---|
1 | Element |
2 | Attribute |
3 | Text |
4 | CDATA Section |
5 | Entity Reference |
6 | Entity |
7 | Processing Introduction |
8 | Comment |
9 | Document |
10 | Document type |
11 | Document Fragment |
12 | Notation |