Properti HTML DOM NodeType
Definisi dan Penggunaan
properti NodeType mengembalikan tipe node.
Jika node adalah node elemen, properti NodeType mengembalikan -1.
Jika node adalah node atribut, properti NodeType kembali 2.
Dukungan Browser
Semua browser utama mendukung properti NodeType
tatabahasa
node .nodeType
rincian teknis
Pengembalian: | String, jenis simpul perwakilan dari node. |
---|---|
versi DOM | Inti Level 1 Node Object |
Node Type
HTML atau dokumen XML file, elemen, atribut, dll Ada berbagai jenis node.
Ada 12 jenis node, jenis node yang berbeda dapat memiliki berbagai jenis node anak:
节点类型 | 描述 | 子节点 | |
---|---|---|---|
1 | Element | 一个元素 | Element, Text, Comment, ProcessingInstruction, CDATASection, Entity参考手册 |
2 | Attr | 一个属性 | Text, Entity参考手册 |
3 | Text | 一个元素的文本内容 或属性 | None |
4 | CDATASection | 一个文档的CDATA部分(文本将 不会被解析器解析) | None |
5 | Entity参考手册 | 实体引用 | Element, ProcessingInstruction, Comment, Text, CDATASection, Entity参考手册 |
6 | Entity | 一个实体 | Element, ProcessingInstruction, Comment, Text, CDATASection, Entity参考手册 |
7 | ProcessingInstruction | 一个处理指令 | None |
8 | Comment | 一个注释 | None |
9 | Document | 整个文档(DOM树的根节点) | Element, ProcessingInstruction, Comment, DocumentType |
10 | DocumentType | 为文档实体提供接口 | None |
11 | DocumentFragment | 表示邻接节点和它们的子树。 | Element, ProcessingInstruction, Comment, Text, CDATASection, Entity参考手册 |
12 | Notation | 代表一个符号在DTD中的声明 | None |
Node Type - Nilai kembali s
Mengembalikan nilai nama node dan simpul jenis setiap nilai simpul properti:
节点类型 | nodeName 返回值 | nodeValue 返回值 | |
---|---|---|---|
1 | Element | 元素名 | null |
2 | Attr | 属性名 | 属性值 |
3 | Text | #text | 节点内容 |
4 | CDATASection | #cdata-section | 节点内容 |
5 | Entity 参考手册 | 实体参考名 | null |
6 | Entity | 实体名 | null |
7 | ProcessingInstruction | target | 节点的内容 |
8 | Comment | #comment | 注释文本 |
9 | Document | #document | null |
10 | DocumentType | doctype name | null |
11 | DocumentFragment | #document fragment | null |
12 | Notation | 符号名称 | null |
Node Type - Static nama variabel
Node类型 | Named Constant |
---|---|
1 | ELEMENT_NODE |
2 | ATTRIBUTE_NODE |
3 | TEXT_NODE |
4 | CDATA_SECTION_NODE |
5 | ENTITY_REFERENCE_NODE |
6 | ENTITY_NODE |
7 | PROCESSING_INSTRUCTION_NODE |
8 | COMMENT_NODE |
9 | DOCUMENT_NODE |
10 | DOCUMENT_TYPE_NODE |
11 | DOCUMENT_FRAGMENT_NODE |
12 | NOTATION_NODE |