Tuesday 16 April 2019

jquery - Need help for parseFloat Values addition

I have 2 divs



 




Its value is updated onclick



0.0301





This is main balance div
I am trying to update

by adding both divs in this way



var totalscore = $("#balance p").text();
var currentscore = $("#cursoc p").text();

var bal = parseFloat(totalscore) + parseFloat(currentscore);
$("#balance p").html(bal);



Ins start it adds correct but After few clicks instead of adding it puts value after the balance like 0.00301000008 instead of adding 0.00301 + 0.000008



Am I doing parseFloat wrong way, need to know what is causing this

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...