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

HTML DOM Input Number value Property

Input Number value Property

Input Number Object Reference Input Number Object

Example

Modify the number in the number field:

document.getElementById("myNumber").value = "16";

Try it »


Definition and Usage

The value property sets or returns the value of the value attribute of the number field.

The value property describes the number entered by the user.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value attribute.

Note: Internet Explorer 9 and earlier versions do not support the HTML using the type="number" attribute .


Syntax

Return the value attribute:

numberObject

.value

Set the value attribute:

numberObject

.value=

number

Attribute values

Value Description
number Describes the initial (default) value of the number field.

Technical Details

Return Value: A string representing a number

More examples

Example

Get the value of the number field:

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

x

The output is:

2

Try it »


Related pages

HTML Reference Manual: HTML value attribute


Input Number Object Reference Input Number Object