1var myNumber=12.2345;
2var myNumberWithTwoDecimalPlaces=parseFloat(myNumber).toFixed(2); //12.23
1var example = 3.35464464374256 ;
2example = parseFloat(example.toFixed(2)) ; // example == 3.35
1var totalAmount = 0;
2totalAmount = Number($("#sub_amount").val()) + Number($("#vat_amount").val());
3totalAmount = totalAmount.toFixed(2);
4$('#total_amount').val(totalAmount);
5//@sujay
1Number(1).toFixed(2); // 1.00
2Number(1.341).toFixed(2); // 1.34
3Number(1.345).toFixed(2); // 1.34 NOTE: See andy's comment below.
4Number(1.3450001).toFixed(2); // 1.35
5