<script language="javascript"> document.write("<h1>JS保留兩位小數例子</h1><br>"); var a=2.1512131231231321; document.write("原來的值:"+a+"<br>"); document.write("兩位小數點:"+a.toFixed(2)+"<br>四位小數點"+a.toFixed(4)); </script>