标签:bsp rip indexof nbsp 保留 round tostring [1] alert
function returnFloat(value) {
var value = Math.round(parseFloat(value) * 100) / 100;
var xsd = value.toString().split(".");
if (xsd.length == 1) {
value = value.toString() + ".00";
return value;
}
if (xsd.length > 1) {
if (xsd[1].length < 2) {
value = value.toString() + "0";
}
return value;
}
}
示例2:
<script>
tmp = "1234567.57232"
result = tmp.substr(0,tmp.indexOf(".")+3);
alert(result);
</script>
标签:bsp rip indexof nbsp 保留 round tostring [1] alert
原文地址:https://www.cnblogs.com/armyin/p/9174418.html