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 times I might have 258.2. In the latter case, I need to add the trailing zero. How would I go about doing this?
I have a script which returns a price for a product. However, the price
Share
You can use javascript’s
toFixedmethod (source), you don’t need jQuery. Example:Edit: Electric Toolbox link has succumbed to linkrot and blocks the Wayback Machine so there is no working URL for the source.