Remove the class attribute from an <h1> element:
document.getElementsByTagName("H1")[0].removeAttribute("class");
Try it Yourself »
Remove the href attribute from an <a> element:
document.getElementById("myAnchor").removeAttribute("href");
Try it Yourself »
The removeAttribute()
method removes an attribute from an element.
The removeAttribute()
method removes an attribute, and does not have a return value.
The removeAttributeNode()
method removes an Attr object, and returns the removed object.
The result will be the same.
element.removeAttribute(
name)
Parameter | Description |
name | Required. The name of the attribute. |
NONE |
element.removeAttribute()
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!