X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM value Property

Attributes Object Reference Attribute Object

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


Examples

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 »


Attributes Object Reference Attribute Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook