HTML DOM removeAttributeNode() 方法

HTML DOM Element 对象

实例

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

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

删除属性之前:

Hello World

删除属性之后:

Hello World

亲自试一试

定义和用法

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

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

参阅 removeAttribute() 方法。

浏览器支持

IE Firefox Chrome Safari Opera
此在线速查手册由www.w┓┏3┓┏x┓┏u┓┏e.com提供,请勿盗用!

所有主流浏览器均支持 normalize() 方法,除了 Internet Explorer。

语法

element.removeAttributeNode(attributenode)

参数

参数 类型 描述
attributenode Attr object 必需。您希望移除的属性节点。
此在线速查手册由www.w┓┏3┓┏x┓┏u┓┏e.com提供,请勿盗用!

返回值

类型 描述
Attr 对象。 被删除的属性节点。
此在线速查手册由www.w┓┏3┓┏x┓┏u┓┏e.com提供,请勿盗用!

技术细节

DOM 版本 Core Level 1 Element Object
此在线速查手册由www.w┓┏3┓┏x┓┏u┓┏e.com提供,请勿盗用!

HTML DOM Element 对象