When i add a number to the input it doesn\'t change the value that stays at 5 and when i go in the console and type uw.value i get \"6\" back instead of 6 which i typed in
Check out HTMLInputElement.valueAsNumber:
The value of the element, interpreted as one of the following in order:
- a time value
- a number
- null if conversion is not possible
var testInput = document.getElementById("test-input");
function handleInput(e){
var value = this.valueAsNumber;
console.log("type: %s, value: %o", typeof value, value);
}
testInput.addEventListener("input", handleInput);
handleInput.call(testInput);
This will return NaN for non-numerics or non-finite numbers.