This page is In Progress

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

setAttribute

Summary

Sets the value of a content attribute.

Method of dom/Elementdom/Element

Syntax

 element.setAttribute(name, value);

Parameters

name

Data-type
String

The name of the attribute.

value

Data-type
String

The value of the attribute.

Return Value

No return value

Notes

  • The attribute will be created, if it is not already present.

Related specifications

Document Object Model (DOM) Level 3 Core
Recommendation
Document Object Model (DOM) Level 2 Core
Recommendation
Document Object Model (DOM) Level 1
Recommendation
DOM
Living Standard

See also

Related pages

Attributions