Reputation: 499
Hopefully someone can help with this. I am simply looking to add the final zero to the decimal part of a price in a price calculator I am written.
The calculator starts with a user selecting a standard "Sign Up" fee of €25.50 and then selecting other packages to increase the price.
At the moment, the standard price displays as €25.5.
costs = jQuery('.cost-container').text();
total = Number(costs) + (25.50).toFixed(2);
I got this code by looking at the following similar query: How to add a trailing zero to a price with jQuery
Currently, if I enter 25.511 as my value, the result displays as 25.51, which shows that the code is sort of working, my issue is just when the second decimal place is 0 that it does not display.
Can anybody spot what is wrong?
Cheers
Damien
Upvotes: 3
Views: 1242
Reputation: 6468
Try
costs = jQuery('.cost-container').text();
total = ( Number(costs) + 25.50 ).toFixed(2);
Upvotes: 1