javascript DOM相关语法

childNodes: 获取元素内的所有节点

        包括文本节点:nodeType=3 ,

        元素节点:nodeType = 1

nodeType:它可以判断所有节点的类型

        元素节点类型:1

       文本节点:3

  注释节点:8

       属性节点:2

节点类型 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

    

猜你喜欢

转载自www.cnblogs.com/chaoyuehedy/p/9186216.html