Sammy Sung
Sammy Sung

Reputation: 311

how to evaluate currency symbols in jquery

I am currently having a bit of an issue with respect to evaluating a currency symbol.

I have the following code:

function updateTax(totalTax)
    {   
        var tax = $(".Tax").attr("title", "Tax: " + (touch.formatCurrency(totalTax, currencySymbol, currencyDesc, currencyMode)));
    }

which currently returns me the following:

Tax: £13.20

I am trying to get the currency symbol to evaluate, in this case, should be £ instead of &pound. I am not sure if this is due to being raw html and it needs to be converted or not, but if it is, how would i go about doing this.

Thanks

Upvotes: 1

Views: 169

Answers (1)

epascarello
epascarello

Reputation: 207527

An easy way to do it is you can set the html of an element and read the text

function getText (str)
  return $("<div>").html(str).text();
}

console.log(getText("Tax: &pound;13.20"));

Upvotes: 1

Related Questions