Remove the class attribute node from an <h1> element:
Before removing the attribute node:
After removing the attribute node:
The removeAttributeNode() method removes the specified attribute from an element, and returns the removed attribute, as an Attr Node object.
The difference between this method and the removeAttribute() method, is that the removeAttribute() method removes the attribute with the specified name, while this method removes the specified Attr object. The result will be the same. Also, the removeAttribute() method has no return value, while this method returns the removed attribute, as an Attr object.
Tip: Use the getAttributeNode() method to return an attribute node of an element.
Tip: Use the setAttributeNode() method to add an attribute node to an element.
Method | |||||
---|---|---|---|---|---|
removeAttributeNode() | Yes | Yes | Yes | Yes | Yes |
Parameter | Type | Description |
---|---|---|
attributenode | Attr object | Required. The attribute node you want to remove |
Return Value: | An Attr object, representing the removed attribute node |
---|---|
DOM Version | Core Level 1 Element Object |
Remove the href attribute node from an <a> element:
Before removing the attribute node:
After removing the attribute node:
HTML Tutorial: HTML Attributes
HTML DOM Reference: The HTML DOM Attribute Object
HTML DOM Reference: removeAttribute() Method
HTML DOM Reference: getAttributeNode() Method
HTML DOM Reference: setAttributeNode() Method