Easy Tutorial
❮ Jsref Regexp Global Met Win Settimeout ❯

HTML DOM setAttribute() Method

Element Object

Example

Set the attribute type of an input element:

Before setting the attribute:

After setting the attribute:

Definition and Usage

The setAttribute() method creates or changes a new attribute.

If the specified attribute already exists, only its value is set.


Browser Support

All major browsers support the setAttribute() method.

Internet Explorer 8 and earlier versions do not support this method.


Syntax

Parameters

Parameter Type Description
attributename String Required. The name of the attribute you want to add.
attributevalue String Required. The value of the attribute you want to add.

Return Value

No return value.

Technical Details

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


Element Object

❮ Jsref Regexp Global Met Win Settimeout ❯