I'm using jQuery to get the value presented by an input button. The value is considered to be an integer, I increment it after one and want to display it.
// Countdown to instant voting button ID countup = $ (this) .closest ('li'). ('Div> Input.green') appears. Attr ('id'); Var calculation = $ ("#" + setup) .val () + 1; Warning (count); The above code gives me a concatenated string. Say for example value 3. I want to get 4 as the output, but the code produces 31.
How can I change the data type of an HTML input value to an integer ?
After
to convert strValue to an integer, either use: parseInt (StrValue, 10); or single + operator. + strValue radix Note that the parameter is due to parseInt because a key 0 is set to parseInt The reason that the input was in octal, and input of 010 would be 8 instead of 10
Comments
Post a Comment