Jquery .toFixed(2) is not a function error - Solved

July 17, 2017 | Category : JQuery

When i was working on core php project and i need to work with float value. Like i require to fixed decimal point with two digit after point. So i did search on google and found the tofixed() of javascript. But when i try and checked on my fire but, it say tofixed() is not a function. I thought what was wrong and i did try many way.

However, Finally i got what is issue and found the best solution. But i did simply use like as bellow example:

var myVal = $(".myfloat").val();

myVal = myVal.tofixed(2);

But above code was not working because i require to use "parseFloat" before use tofixed(), So i did simply use as bellow code:

Solution:

var myVal = $(".myfloat").val();

myVal = parseFloat(myVal).tofixed(2);

I hope you found your solution....