HTML DOM valueProperty
Example
Return the attribute value:
document.getElementsByTagName("button")[0].attributes[0].value;
Output result:
myfunction()
Try it Yourself »
Set the attribute value
Example
Set the style attribute of the head element:
var h=document.getElementsByTagName("H1")[0];
h.getAttributeNode("style").value="color:green";
h.getAttributeNode("style").value="color:green";
Before style attribute modification:
Hello World
After style attribute modification:
Hello World
Try it Yourself »
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
Set the attribute value
attribute.value=value
Return the attribute value
attribute.value
Technical Details
| Return value: | String, representing the attribute's value. |
|---|---|
| DOM Version | Core Level 1 |
Other Extensions
Attribute Object