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():
<!DOCTYPE html> <html> <body> <input type="number" id="myNumber" value="2"> <button onclick="myFunction()">get the number of the number field</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j a v a 2 s. com*/ var x = document.getElementById("myNumber").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>