samedi 23 juillet 2016

Calculate (add up) with dot / comma

I'm trying to add +20,2 to this sum with dot 9990.95 or this sum with comma 9990,95 with js or jquery

<span class="sum">9990.95</span>

var price = $( '.sum' ).text(),
    calc  = parseInt( price, 10 ) + 20,
    total = calc.toFixed( 2 );

Return me 9990 without decimal

I tried like this too

var price = $( '.sum' ).text(),
    calc  = 20,
    total = price + calc;

The output was 9990.9920, which is not correct either.

Is there a way how to do that?

Aucun commentaire:

Enregistrer un commentaire