An inputs value is always a string, and adding a string with a number will always end up as a string.
To solve it, convert the string to a number with either parseInt
or parseFloat
, depending on what the value is (integer or float), or just convert it to a Number type with a plus operator in front of it:
var y = +$("#text").val();
var z = 10;
var x = y+z;