<input type="number" id="number-field">
<p>値の型は...「<span id="type"></span>」</p>
var field = document.getElementById("number-field");
var typeName = document.getElementById("type");
var setType = function(val) {
typeName.innerText = typeof val;
}
field.addEventListener("input", function(e) {
setType(e.target.value);
})
window.onload = function() {
field.value = 20; // 最初に数値を入れても...
setType(field.value);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.