Trying to format number to 2 decimal places jQuery [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: JavaScript: formatting number with exactly two decimals Getting a bit muddled up using variables and now cant seem to get calculation to work at all!? $("#discount").change(function(){ var list = $("#list").val(); var discount = $("#discount").val(); var price = $("#price"); var temp = discount * list; var temp1 = list - temp; var total = parseFloat($(this).temp1()).toFixed(2); price.val(total); }); 回答1: $(this)