<script type="text/javascript">
var x = 4.23323;//測試的數字
var y = String(x).indexOf(".") + 1;//獲取小數點的位置
var count = String(x).length - y;//獲取小數點后的個數
if(y > 0) {
alert("這個數字是小數,有" + count + "位小數");
} else {
alert("不是小數");
}
</script>
//保留n位小數 function roundFun(value, n) { return Math.round(value*Math.pow(10,n))/Math.pow(10,n); }
