Set the class attribute node of a header element:
Before setting the attribute node:
After setting the attribute node:
The setAttributeNode() method adds the specified attribute node to an element.
If the specified attribute allready exists, this method replaces it.
![]()
The setAttributeNode() method is supported in all major browsers.
| Parameter | Type | Description |
|---|---|---|
| attributenode | Attr object | Required. The attribute node you want to add |
| Type | Description |
|---|---|
| Attr object | The replaced attribute node, if any, otherwise null |
| DOM Version | Core Level 1 |
|---|
Your message has been sent to W3Schools.