Attr 类型
存在于元素 attributes 属性中的节点。
特征:
- nodeType 等于2
- nodeName 为属性名
- nodeValue 为属性值
- parentNode 为null
- 在HTML中不支持子节点
- 在XML中子节点可以是Text或EntityReference
在 Attr 对象上有 3 个属性,name、value、specified。
- name 为属性名
- value 为属性值
- specified 为布尔值,表示属性是否显式指定
用 document.createAttribute() 方法创建 Attr 对象。