convert a JavaScript string variable to decimal/money

后端 未结 7 1254
盖世英雄少女心
盖世英雄少女心 2020-12-07 14:05

How can we convert a JavaScript string variable to decimal?

Is there a function such as:

parseInt(document.getElementById(amtid4).innerHTML)
         


        
7条回答
  •  無奈伤痛
    2020-12-07 14:09

    An easy short hand way would be to use +x It keeps the sign intact as well as the decimal numbers. The other alternative is to use parseFloat(x). Difference between parseFloat(x) and +x is for a blank string +x returns 0 where as parseFloat(x) returns NaN.

提交回复
热议问题