Javascript Reference - HTML DOM Input Number type Property








The type property get the type of the input number field.

Browser Support

type Yes 10.0 Yes Yes Yes

Syntax

var v = numberObject.type

Return Value

A String type value representing the type of the number field.





Example

The following code shows how to get the type of the number field.


<!DOCTYPE html>
<html>
<body>
<input type="number" id="myNumber" value="2">
<button onclick="myFunction()">test</button>
<!--from  ww w . j a v a2 s . c o  m-->
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myNumber").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: