Set a H1's class attribute:
Before setting the attribute:
After setting the attribute:
The setNamedItem() method adds the specified node to the nodeMap.
If the node allready exists, it will be replaced, and the replaced node will be the return value, otherwise the return value will be null.
![]()
The setNamedItem() method is supported in all major browsers.
| Parameter | Type | Description |
|---|---|---|
| node | Node object | Required. The node you want to add/replace in the namedNodeMap collection |
| Type | Description |
|---|---|
| Node object | The replaced node, if any, otherwise null |
| DOM Version | Core Level 1 |
|---|
Your message has been sent to W3Schools.