DOMElement::setAttributeNode

Adds new attribute node to element

&reftitle.description; public ``DOMAttr``null``false```DOMElement::setAttributeNode` `DOMAttr` `attr`

Adds new attribute node `attr` to element. If an attribute with the same name already exists on the element, that attribute is replaced by `attr`.

&reftitle.parameters;

`attr`

- The attribute node.

&reftitle.returnvalues;

Returns the old attribute if it has been replaced or &null; if there was no old attribute. If a `DOM_WRONG_DOCUMENT_ERR` error is raised, and `strictErrorChecking` is &false;, &false; is returned.

&reftitle.errors;

`DOM_WRONG_DOCUMENT_ERR`

- Raised if `attr` belongs to a different document than the element.

&reftitle.seealso;

- `DOMElement::hasAttribute`
- `DOMElement::getAttributeNode`
- `DOMElement::removeAttributeNode`