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

Button value Property

Button Object Reference Button Object

Example

Return the value of the value attribute of a button:

var x = document.getElementById("myBtn").value;

The result of x will be:

myvalue

Try it yourself »


Definition and Usage

The value property sets or returns the value of the value attribute of a button.

The value attribute specifies the underlying value that is associated with a button.

Important: If you use the <button> element in an HTML <form>, different browsers will submit different values. Internet Explorer will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.


Syntax

Return the value property:

buttonObject.value

Set the value property:

buttonObject.value=text

Property Values

Value Description
text The initial value of the button

Technical Details

Return Value: A String, representing the underlying value that is associated with the button


More Examples

Example

Change the value of the value attribute of a button:

document.getElementById("myBtn").value = "newButtonValue";

Try it yourself »


Related Pages

HTML reference: HTML <button> value attribute


Button Object Reference Button 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