Possible Duplicate:
JavaScript: formatting number with exactly two decimals
How do I limit the following jQuery return to 2 decimal places?
$("#diskamountUnit").val('$' + $("#disk").slider("value") * 1.60);
I figure I’ve got to throw toFixed(2) somewhere into there, but I can’t seem to get the ordering right or something.
You could use a variable to make the calculation and use
toFixedwhen you set the#diskamountUnitelement value:You can also do that in one step, in the
valmethod call but IMO the first way is more readable: