📜  javascript tofixed 不是函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:49.658000             🧑  作者: Mango

代码示例1
toFixed isn't a method of non-numeric variable types. In other words, Low and High can't be fixed because when you get the value of something in Javascript, it automatically is set to a string type. Using parseFloat() (or parseInt() with a radix, if it's an integer) will allow you to convert different variable types to numbers which will enable the toFixed() function to work.

var Low  = parseFloat($SliderValFrom.val()),
    High = parseFloat($SliderValTo.val());