Input Number value Property - Get the number of a number field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

Input Number value Property - Get the number of a number field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Number: <input type="number" id="myNumber" value="2">

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//from  w ww  .  j  a v a 2 s.  c  o  m
    var x = document.getElementById("myNumber").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials