javascript - Add two variables using jquery -
var = 1; var b = 2; var c = a+b;   c show 12; need 3
how do using jquery?
it looks have strings , not numbers, need parseint() or parsefloat() (if may decimals) here, this:
var = "1"; var b = "2"; var c = parseint(a, 10) + parseint(b, 10); //or: var c = parsefloat(a) + parsefloat(b);   you can test difference here, it's worth noting these not jquery base javascript functions, isn't dependent on jquery library in way.
Comments
Post a Comment