+ 1
How to get input value as a number in javascript?
input value return as a string.
3 Answers
+ 4
Number() will auto-cast float or int, but you can also use parseInt() or parseFloat() if you want to force to a specific type ^^
+ 1
var yourString = "12";
var number = Number(yourString);
Jquery example with input:
var value = Number($("input").val());
0
var num = 12;