removeAttributeNode()


定义和用法

removeAttributeNode() 方法删除指定的属性,并以 Attr Node 对象返回被删除的属性。

此方法与 removeAttribute() 方法的差异是,removeAttribute() 方法返回具有指定名称的属性,而此方法删除指定的 Attr 对象。结果是相同的。同时,removeAttribute() 方法没有返回值,而此方法返回被删除的属性,以 Attr 对象的形式。

参阅 removeAttribute() 方法。

实例

删除 header 元素的 style 属性节点:

var n=document.getElementsByTagName("INPUT")[0];
var a=n.getAttributeNode("type");
n.removeAttributeNode(a)