HTML DOM value Property
Example
Returns the attribute value:
document.getElementsByTagName("button")[0].attributes[0].value;
Output result:
myfunction()
Try it »
Sets the attribute value.
Example
Set the style attribute of the header element:
var h=document.getElementsByTagName("H1")[0];
h.getAttributeNode("style").value="color:green";
Before modifying the style attribute:
Hello World
After modifying the style attribute:
Hello World
Try it »
Definition and Usage
The value property is used to set or return the value of an attribute.
Browser support





All major browsers support the value property.
Syntax
Sets the attribute value.
attribute
.value=
value
Returns the attribute value.
attribute
.value
Technical Details
| Return Value: | A string representing the value of the attribute. |
|---|---|
| DOM version | Core Level 1 |
Attribute object