I got a list with prices inside and I want to get these (in this example one) to use them later for a calculation.
My idea was to get it as a string, convert it to a decimal and then do my calculation with it. The other idea would be to get the string and remove the
and the €
but I think the conversion into a number is better, isn't it?
paidNettoWithShipping = parseFloat($('.aggregation--list .entry--totalnet .entry--value').text()).toFixed(2);
console.log(paidNettoWithShipping);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="aggregation--list">
<div class="entry--totalnet">
<div class="entry--value">21,01 €</div>
</div>
</div>
The problem here is, that my numbers gets rounded to 21.00
instead of the correct 21.01
is this because of the ,
instead of .
in my html? Thats how we write currency in europe, so I won't change that.
How do I get my correct number to use it later in some calculations?