YouTip LogoYouTip

Prop Number Value

HTML DOM Input Number value Property

HTML DOM Input Number value Property

-- Learning is not just about technology, but also about dreams!

JavaScript Reference

Overview

JavaScript Objects

JavaScript Array Object JavaScript Boolean Object JavaScript Date Object JavaScript Math Object JavaScript Number Object JavaScript String Object JavaScript RegExp Object JavaScript Global Properties/Functions JavaScript Operators JavaScript Error

Browser Objects

Window Object Navigator Object Screen Object History Object Location Object Storage Object

DOM Objects

HTML DOM Document Object HTML DOM Element Object HTML DOM Attribute Object HTML DOM Event Object HTML DOM Console Object CSSStyleDeclaration Object DOM HTMLCollection

HTML Objects

<a> <area> <audio> <base> <blockquote> <body> <button> <canvas> <col> <colgroup> <datalist> <del> <details> <dialog> <embed> <fieldset> <form> <iframe> <frameset > <img> <ins> <input> - button <input> - checkbox <input> - color <input> - date <input> - datetime <input> - datetime-local <input> - email <input> - file <input> - hidden <input> - image <input> - month <input> - number <input> - range <input> - password <input> - radio <input> - reset <input> - search <input> - submit <input> - text <input> - time <input> - url <input> - week <keygen> <link> <label> <legend> <li> <map> <menu> <menuItem> <meta> <meter> <object> <ol> <optgroup> <option> <param> <progress> <q> <script> <select> <source> <style> <table> <td> <th> <tr> <textarea> <title> <time> <track> <video>

<input> - month <input> - range

Input Number value Property

Input Number Object Reference Input Number Object

Example

Change the number in a number field:

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

Try it yourself Β»


Definition and Usage

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

The value property describes the number entered by the user.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The value property is supported in all major browsers.

Note: Internet Explorer 9 and earlier do not support <input> elements with type="number".


Syntax

Return the value property:

numberObject.value

Set the value property:

numberObject.value=number

Property 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 number value of a number field:

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

The value of x will be:

2

Try it yourself Β»


Related Pages

HTML Reference: HTML <input> value Attribute


Input Number Object Reference Input Number Object

<input> - month <input> - range

← Dom Obj RangeProp Number Type β†’