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

Javascript examples for DOM HTML Element:Input Number

Description

Input Number defaultValue Property - Get the default value 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 type="button" onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//  ww  w.  java2 s .  c o m
    var x = document.getElementById("myNumber").defaultValue;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials