How to add a trailing zero to a price with jQuery

后端 未结 3 817
刺人心
刺人心 2020-12-01 17:49

So I have a script which returns a price for a product. However the price may or may not include trailing zeros so sometimes I might have:

258.22

and other t

3条回答
  •  温柔的废话
    2020-12-01 18:33

    Javascript has a function - toFixed - that should do what you want ... no JQuery needed.

    var n = 258.2;
    n.toFixed (2);  // returns 258.20
    

提交回复
热议问题