//Amount format conversion
function parsePrice(s) {
var n = 2 //Set the number of decimal places to retain
s = parseFloat((s "").replace(/[^d.-]/g, "")).toFixed(n) "" ;
var l = s.split(".")[0].split("").reverse();
var r = s.split(".")[1];
var t = "";
for (i = 0; i < l.length; i ) {
t = l[i];
}
return '¥' t.split( "").reverse().join("") "." r;
}
Use:
var m=10;
parsePrice(m);//Output: ¥10.00
var m=12.2
parsePrice(m);//Output: ¥12.20
var m=12.31
parsePrice(m);//Output: ¥12.31
Other information: In the browser according to the URL settings, reopen a tab:
window.open("http://www.allinpay.com");