HTML DOM removeAttribute() 方法

HTML DOM removeAttribute() 方法

元素对象参考手册 元素对象

实例

删除头部元素的 style 属性:


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

删除属性前:


Hello World

删除属性后:


Hello World


知识兔 »

定义和用法

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

查看类似方法 removeAttributeNode()

浏览器支持

所有主要浏览器都支持 removeAttribute() 方法

语法

element.removeAttribute(attributename)

参数s

参数类型 描述
attributenameString必需。规定要删除的属性的名称。

返回值

没有返回值。

技术细节

DOM 版本Core Level 1 Element Object

元素对象参考手册 元素对象

计算机