开发者

Converting formatted string to integer in Javascript

how can i conve开发者_JAVA技巧rt "570.581,88" into an integer and sort accordingly?


var s = "570.581,88";

// Format as American input
s = s.replace(/\./g,'').replace(',','.');

// Integer
var i = parseInt(s,10);

// Floats
var f1 = parseFloat(s);
var f2 = s*1;
var f3 = +s;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜