Change the number of a number field:
The value property sets or returns the value of the value attribute of a number field.
The value attribute specifies the default value OR the value a user types in (or a value set by a script).
The value property is supported in all major browsers.
Note: The <input type="number"> element is not supported in Internet Explorer 9 and earlier versions.
Return the value property:
Set the value property:
Value | Description |
---|---|
number | Specifies the initial (default) value of the number field |
Return Value: | A String, representing a number |
---|
Get the number of a number field:
The result of x will be:
An example that shows the difference between the defaultValue and value property:
HTML reference: HTML <input> value attribute