ການລຶບປະເພດຂອງ HTML DOM Element removeAttribute()
- Previous Page remove()
- Next Page removeAttributeNode()
- Back to Top ໂອບເອັມໂດມຂອງເອສໂອເມເລ
Definition and usage
removeAttribute()
Method removes an attribute from the element.
Tip:The operation of deleting a non-existent attribute or an attribute that is not set but has a default value will be ignored.
The difference between removeAttribute() and removeAttributeNode()
removeAttribute()
Method deletes attribute and does not return a value.
removeAttributeNode()
Method deletes Attr object and returns the removed object.
The result will be the same.
See also:
Reference manual:
Tutorial:
Example
Example 1
Remove the class attribute from the <h1> element:
document.getElementsByTagName("H1")[0].removeAttribute("class");
Example 2
Remove the href attribute from the <a> element:
document.getElementById("myAnchor").removeAttribute("href");
Syntax
element.removeAttribute(name)
Parameter
Parameter | Description |
---|---|
name | Required. The name of the attribute. |
Return value
None.
Throw
If the element is read-only and does not allow deleting its attributes, this method will throw a DOMException exception with code NO_MODIFICATION_ALLOWED_ERR.
Browser support
element.removeAttribute()
Is DOM Level 1 (1998) feature.
All browsers fully support it:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | 9-11 | Support | Support | Support | Support |
- Previous Page remove()
- Next Page removeAttributeNode()
- Back to Top ໂອບເອັມໂດມຂອງເອສໂອເມເລ