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>
原文地址:https://www.cnblogs.com/armyin/p/9174418.html
时间: 2024-10-09 00:59:32