将HTML DOM中几个常用的属性做下介绍,工作中作为参考。
nodeName 属性可依据节点的类型返回其名称。
元素节点的 nodeName 是标签名称
属性节点的 nodeName 是属性名称
文本节点的 nodeName 永远是 #text
文档节点的 nodeName 永远是 #document
注:nodeName 所包含的 XML 元素的标签名称永远是大写的。
nodeValue 属性设置或返回指定节点的节点值。
对于文本节点,nodeValue 属性包含文本。
对于属性节点,nodeValue 属性包含属性值。
nodeValue 属性对于文档节点和元素节点是不可用的
nodeType 属性返回被选节点的节点类型。
| 节点编号: | 节点名称: |
| 1 | Element |
| 2 | Attribute |
| 3 | Text |
| 4 | CDATA Section |
| 5 | Entity Reference |
| 6 | Entity |
| 7 | Processing Instrucion |
| 8 | Comment |
| 9 | Document |
| 10 | Document Type |
| 11 | Document Fragment |
| 12 | Notation |
获取元素属性值的方法:element是进行操作的元素
element.nodeName
element.nodeValue
element.nodeType