How to convert a currency string to a double with jQuery or Javascript?

后端 未结 19 2468
天涯浪人
天涯浪人 2020-11-22 17:30

I have a text box that will have a currency string in it that I then need to convert that string to a double to perform some operations on it.

\"$1,1

相关标签:
19条回答
  • 2020-11-22 18:10

    This example run ok

    var currency = "$1,123,456.00";
    var number = Number(currency.replace(/[^0-9\.]+/g,""));
    console.log(number);

    0 讨论(0)
提交回复
热议问题