I want to be able to retrieve a number value from a cookie but limit the number to 2 decimal places. The value is stored in a cookie as a result of a change function that calculates, dynamically, a price given preset variable values. Sometimes that number displays as 34.000012, for example. I store the value in a cookie using this:
$(function () {
$("#btnCookie").bind("click", function () {
$.cookie("name", $("#txtName").val());
$.cookie("amount", $("#txtAmount").val());
I retrieve the value using this:
<b>Amount:</b> $" + $.cookie("amount")
Since it's supposed to be a price, I'd like it to display only two values after the decimal. How can I accomplish this?
EDIT: This question is different than the alleged duplicate because the value is the result of a change function that calculates price in dollars, the user below has posted the answer I've been seeking. Thanks!