Easy Tutorial
❮ Met Table Createcaption Prop Video Defaultplaybackrate ❯

HTML DOM setAttributeNode() Method

Element Object

Example

Before setting the attribute node:

Hello World

After setting the attribute node:

Hello World

Definition and Usage

The setAttributeNode() method is used to add a new attribute node.

If the element already contains an attribute with the specified name, it will be replaced by the new attribute. If the new attribute replaces an existing one, the replaced attribute is returned; otherwise, it returns NULL.


Browser Support

All major browsers support the setAttributeNode() method.


Syntax

Parameters

Parameter Type Description
attributenode Attr object Required. The attribute node you want to add.

Return Value

Type Description
Attr object The replaced attribute node, or null if none.

Technical Details

| DOM Version | Core Level 1 Element Object | | --- | --- |


Element Object

❮ Met Table Createcaption Prop Video Defaultplaybackrate ❯