天天看点

HTML DOM removeAttributeNode() 方法Hello WorldHello World

HTML DOM removeAttributeNode() 方法Hello WorldHello World

元素对象

删除头部元素的属性节点:

var n=document.getElementsByTagName("INPUT")[0];

var a=n.getAttributeNode("type");

n.removeAttributeNode(a)

移除属性前:

移除属性后:

removeAttributeNode() 方法从元素中删除指定的属性节点。

该方法从当前元素的属性集合中删除(并返回)一个 Attr 节点。如果 DTD 给删除的属性设置了默认值,那么该方法将添加一个新的 Attr 节点,表示这个默认值。用 removeAttribute() 方法代替该方法往往会更简单。

你可以参照 removeAttribute()

方法。

HTML DOM removeAttributeNode() 方法Hello WorldHello World
HTML DOM removeAttributeNode() 方法Hello WorldHello World
HTML DOM removeAttributeNode() 方法Hello WorldHello World
HTML DOM removeAttributeNode() 方法Hello WorldHello World
HTML DOM removeAttributeNode() 方法Hello WorldHello World

除了 Internet Explorer 浏览器,所有主流浏览器都支持 removeAttributeNode() 方法

element.removeAttributeNode(attributenode)

参数

类型

描述

attributenode

Attr object

必须。你想移除的属性节点。

Attr 对象

移除的属性节点

DOM 版本

Core Level 1 Element Object

HTML DOM removeAttributeNode() 方法Hello WorldHello World