Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM value Property

HTML DOM value Property

Attribute Object Reference Attribute object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Attribute object