6.3 Atrribute对象


Attr 对象

在 HTML DOM 中,Attr对象表示 HTML 属性。

HTML 属性始终属于 HTML 元素。

attr.isId 如果属性是id类型,则返回true,否则返回false
attr.name 返回属性的名称
attr.value 设置或返回属性的值
attr.specified 如果已指定属性,则返回true,否则返回false
nodemap.getNamedItem() 从NamedNodeMap返回指定的属性节点
nodemap.item() 返回NamedNodeMap中位于指定下标的节点
nodemap.length 返回NamedNodeMap中的节点
nodemap.removeNameItem() 移除指定的属性节点
nodemap.setNamedItem() 设置指定的属性节点(通过名称)

在 W3C DOM Core 中,Attr (attribute) 对象从 Node 对象继承所有属性和方法。

在 DOM 4 中,Attr 对象不再从 Node 继承。

为了保证未来的代码安全,您应该避免在属性对象上使用节点对象的属性和方法:


http://www.w3school.com.cn/jsref/dom\_obj\_attributes.asp

results matching ""

    No results matching ""