function changeNum(num){ var numArr=num.toString().split('.'); var temArr=[]; var lastArr=[]; for (var i=numArr[0].length;i>0;i-=3) { temArr.unshift(numArr[0].substring(i-3,i)); } lastArr.push(temArr.join(',')); lastArr.push(numArr[1]); return lastArr.join('.'); }