这是代码:
function updateCartSubtotal() {
var subtotal = 0.00;
$('span.item-subtotal-value').each(function () {
subtotal = subtotal + parseFloat($(this).text()); //24.00 for example.
});
console.log(subtotal); // Logs: "144"
$('span.cart-subtotal-value').text(subtotal); //Places: "144" in the .text().
$('span.cart-subtotal').text(subtotal);
}
那么我做错了什么?为什么这忽略了两个尾随零?
它添加正确,只是不显示小数。