Javascript 使用jquery对总值进行四舍五入

Javascript 使用jquery对总值进行四舍五入,javascript,jquery,Javascript,Jquery,如何将总计1的值四舍五入到3位小数?Number.toFixed(n) 这是原生JS,不需要特定的JQuery函数 $(this).closest('table').find('.total1').val(($(this).closest('table').find('.total').val() * price) / $(this).closest('table').find('.inrvalue').val()); 您可以将total1值分配到不同的变量中,并执行以下操作: var val

如何将总计1的值四舍五入到3位小数?

Number.toFixed(n)

这是原生JS,不需要特定的JQuery函数

$(this).closest('table').find('.total1').val(($(this).closest('table').find('.total').val() * price) / $(this).closest('table').find('.inrvalue').val());

您可以将total1值分配到不同的变量中,并执行以下操作:

var value = 10.123456.toFixed(3);
// value = 10.123

您需要使用javascript,jquery没有数学库
   var total1= 4.34597;
   var total1Rounded= Math.round(total1* 1000) / 1000;