天天看點

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