亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

HTML DOM removeAttribute() 方法

HTML DOM Element 對象

removeAttribute()方法從元素中刪除具有指定名稱的屬性。

注意:由于removeAttribute()不返回值,所以不能將多個調(diào)用鏈接在一起來一次性刪除多個屬性。

使用getAttribute()方法可返回元素的屬性值。

使用setAttribute()方法可添加新屬性或更改元素上現(xiàn)有屬性的值。

語法:

element.removeAttribute(attrName)
document.getElementsByTagName("H1")[0].removeAttribute("class");
測試看看?/?

瀏覽器兼容性

所有瀏覽器完全支持removeAttribute()方法:

Method
removeAttribute()

參數(shù)值

參數(shù)描述
attrName字符串,表示要從元素中刪除的屬性的名稱

技術(shù)細節(jié)

返回值:Undefined
DOM版本:DOM 2級

更多示例

找出錨元素是否具有href屬性。如果存在href,使用removeAttribute刪除href屬性:

var a = document.getElementById("myLink");

if (a.hasAttribute("href")) {
a.removeAttribute("href");
}
測試看看?/?

相關(guān)參考

HTML教程:HTML屬性

HTML DOM參考:getAttribute()方法

HTML DOM參考:setAttribute()方法

HTML DOM參考:hasAttribute()方法

HTML DOM Element 對象