Easy Tutorial
❮ Prop Submit Disabled Jsref Regexp I ❯

HTML DOM createAttribute() Method

Document Object

Example

Create a class attribute with the value "democlass" and add the class attribute to the H1 element:

Before adding the attribute:

Hello World

After adding the attribute:

Hello World


Definition and Usage

The createAttribute() method is used to create an attribute with the specified name and returns an Attr object attribute.


Browser Support

All major browsers support the createAttribute() method.


Syntax

Parameters

Parameter Type Description
attributename Attr object Required. The name of the attribute to create.

Return Value

Type Description
Node object The created attribute

Technical Details

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


Document Object

❮ Prop Submit Disabled Jsref Regexp I ❯