Get Input Number Field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number


The Input Number object represents an HTML <input> element with type="number".

You can access an <input> element with type="number" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<input type="number" id="myNumber" value="2">

<button onclick="myFunction()">get the number of the number field</button>

<p id="demo"></p>

function myFunction() {/*from  w w  w .  j a  v a  2 s.  com*/
    var x = document.getElementById("myNumber").value;
    document.getElementById("demo").innerHTML = x;


Related Tutorials