I want to convert the value of an element, say, an input into a number so I can add numbers. My current code only adds the number to the end:
var inputValue = document.getElementById("input").value;
console.log(inputValue + 9);
<input id="input" value="123">
I have tried Number()
but that results in NaN
. How can I obtain the number value and add a number to it?
Update: I've solved my own question. Oops. Thanks everyone who helped.