HTML DOM value Property
Example
Get the value of the <button> element's first attribute:
var x =
document.getElementsByTagName("BUTTON")[0].attributes[0].value;
The result of x will be:
myFunction()
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The value property sets or returns the value of the attribute.
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the attribute value
attribute.value
Set the attribute value
attribute.value=value
Property Values
Value | Description |
---|---|
value | Specifies the value of the attribute |
Technical Details
Return Value: | A String, representing the value of the attribute |
---|---|
DOM Version | Core Level 1 |
More Examples
Example
Change the value of the src attribute of an <img> element:
var x = document.getElementsByTagName("IMG")[0];
x.getAttributeNode("src").value = "pic_bulbon.gif";
Before changing the style:
After changing the style:
Try it Yourself »