一、四舍五入取整数 Math.round()
console.log(Math.round(2.5));//3
console.log(Math.round(2.4));//2
结果:3
二、取整数部分,不四舍五入 parseInt()
$("#order_total").html(parseInt(total));
console.log(parseInt(2.5));//2
console.log(parseInt(2.4));//2
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/221171.html原文链接:https://javaforall.net
