HTML DOM Element setAttribute()
HTML DOM Element setAttribute() Method
The setAttribute() method is used to set a new value to an attribute. It will create attribute if it does not exist.
Syntax:-
Its syntax is:- element.setAttribute(name, value)
Further Explanation:-
Parameter | Description |
name | Required. The name of the attribute. |
value | Required. The new attribute value. |