天天看點

HTML DOM removeAttribute() 方法Hello WorldHello World

HTML DOM removeAttribute() 方法Hello WorldHello World

元素對象

删除頭部元素的 style 屬性:

document.getElementsByTagName("H1")[0].removeAttribute("style");

删除屬性前:

删除屬性後:

 removeAttribute() 方法删除指定的屬性

檢視類似方法

removeAttributeNode() 。

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

所有主要浏覽器都支援 removeAttribute() 方法

element.removeAttribute(attributename)

參數

類型

描述

attributename

String

必需。規定要删除的屬性的名稱。

沒有傳回值。

DOM 版本

Core Level 1 Element Object

HTML DOM removeAttribute() 方法Hello WorldHello World