且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在javascript中添加两个值

更新时间:2023-08-01 15:50:46

使用 parseInt()将字符串转换为整数。

Use parseInt() to cast your strings as integers.

var math= parseInt(x,10) + parseInt(y,10);

参见 https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt