Liny_@NotePad

沉迷ACG中

js小数的四舍五入。。

YOYO posted @ 2009年12月03日 21:25 in 【Web开发】客户端 , 2311 阅读

调用toFixed(n)函数即可。。。n表示保留n位小数,eg:

  1.                 function countTotalPrice(num) {
  2.                         var x = num * ${requestScope.good.retailPrice};
  3.                         document.getElementById("totalPrice").value = x.toFixed(2);
  4.                 }
  • 无匹配

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter