Latest web development tutorials

HTML DOM removeAttributeNode() 方法

元素對象參考手冊 元素對象

實例

刪除頭部元素的屬性節點:

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

移除屬性前:

Hello World

移除屬性後:

Hello World


嘗試一下»

定義和用法

removeAttributeNode() 方法從元素中刪除指定的屬性節點。

該方法從當前元素的屬性集合中刪除(並返回)一個Attr 節點。 如果DTD 給刪除的屬性設置了默認值,那麼該方法將添加一個新的Attr 節點,表示這個默認值。 用removeAttribute() 方法代替該方法往往會更簡單。

你可以參照removeAttribute()方法。


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


語法

element .removeAttributeNode( attributenode )

參數

参数 类型 描述
attributenode Attr object 必须。你想移除的属性节点。

返回值

类型 描述
Attr 对象 移除的属性节点

技術細節

DOM 版本 Core Level 1 Element Object


元素對象參考手冊 元素對象