Why does Firebug say toFixed() is not a function?

前端 未结 5 1723
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-23 19:57

I am using jQuery 1.7.2 and jQuery UI 1.9.1. I am using the code below within a slider. (http://jqueryui.com/slider/)

I have a function that should test two values a

5条回答
  •  悲哀的现实
    2020-12-23 20:52

    Low is a string.

    .toFixed() only works with a number.

    A simple way to overcome such problem is to use type coercion:

    Low = (Low*1).toFixed(..);
    

    The multiplication by 1 forces to code to convert the string to number and doesn't change the value. JSFiddle code here.

提交回复
热议问题