I’m trying to get the added total of an attribute value. The value is either a monetary sum eg. $29.99, or a text string, eg. sold.
I’m using the following code, which I’m sure is not proper. I get a returned value of NaN, which I know means “not a number”. I have a feeling I may not be properly removing the text string, dollar sign, commas, or all three.
Any help in providing a proper solution is much appreciated. Thanks.
var total = parseFloat($('span.buyoffer').attr('data-price').replace(/[A-Za-z$-]/g, ""));
1 Answer