Input Number type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

The type property returns the type of form element week field.

For an input number, it will always return "number".

Return Value

A String, representing the type of form element the number field is

The following code shows how to return which type of form element the number field is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

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

</body>
</html>

Related Tutorials