128
rated 0 times
[
134]
[
6]
/ answers: 1 / hits: 6464
/ 11 Years ago, sat, december 28, 2013, 12:00:00
I have problem with calcualting float values via javascript.
first my code
var d_val = 0.00;
$.each($('.prices a b'), function(index,obj){
d_val = parseFloat( $(obj).text().replace( '€', '' ) );
group_price += d_val;
});
console.log( '-----> '+ group_price );
when i run this code when adding new elements into .prices firebug prints...
-----> 0.8
-----> 1.6
-----> 2.4000000000000004
-----> 3.2
$('.prices a b') has alltime a string like 0.80€ or 0.50€
Does somebody has an idea, what the problem is?
More From » jquery