removeAttribute() 方法删除指定的属性
查看类似方法 removeAttributeNode() 。
所有主要浏览器都支持 removeAttribute() 方法
element.removeAttribute(attributename)
参数 | 类型 | 描述 |
---|---|---|
attributename | String | 必需。规定要删除的属性的名称。 |
没有返回值。
DOM 版本 | Core Level 1 Element Object |
---|
删除头部元素的 style 属性:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web176教程网(web176.com)</title> </head> <body> <h1 style="color:red">Hello World</h1> <p id="demo">点击下面的按钮删除上面的标题的样式属性</p> <button >