开发者

Add a 0 to the end of a decimal number to make sure it's always 2 decimals?

I am using the following code to work out an inc and ext VAT price:

$('#totalexvat').text开发者_Go百科(totalprice);
var vat = totalprice / 100 * 17.5;
vat = roundNumber(vat,2);
$('#totalincvat').text(totalprice-vat);

Sometimes I get .3 or .9 instead of what I would like to be .30 or .90 because it's money, is there a way to do this?


You may want to look at this: http://code.google.com/p/jquery-numberformatter/ since you're using jQuery already.


try toFixed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜