我有一些修改,我需要为我的成本计算器:
有没有办法到Math.celi添加到无罐所以向上舍入到最接近的整数,提供所需的最低罐?
有史以来最低要求的罐是什么,可以将成本反映由18.23乘以并给予实际金额是多少?
$('input').keyup(function () { // run anytime the value changes var firstValue = parseFloat($('#width').val()); // get value of field var secondValue = parseFloat($('#height').val()); var thirdValue = parseFloat($('#per-can').val()); // convert it to a float var forthValue = parseFloat($('#cost').val()); var fithValue = parseFloat($('#size').val()); var canCount = firstValue * secondValue / thirdValue; $('#added').html((canCount * forthValue).toFixed(2)); $('#cans').html(canCount.toFixed(2)); if (Math.ceil(canCount) < 2) { $('#error').html("Need at least 1!"); } else { $('#error').empty(); } });
http://jsfiddle.net/5xzSy/504/感谢