0
I have a function to change quantity in the shopping cart and I need to limit the number of decimals, because if I add more than 2 units the value is like this: 89.69999999999
Example: https://codepen.io/bombcat/pen/4e482b3f6f96e7c90213f7c887738c1b
Html:
<div class="quantity" id="product1">
<input style="font-size:21px;" type="button" value="-" onclick='javascript: document.getElementById("number").value--;' class="operator">
<input id="number" type="number" value="1" class="qty" name="picpac" disabled>
<input style="font-size:21px;" type="button" value="+" onclick='javascript: document.getElementById("number").value++;' class="operator">
</div>
<input type="hidden" id="product1_base_price" value="29.90">
<div id="product1_total_price">
29.90
</div>
javascript
$(document).ready(function() {
$(".operator").on('click',function() {
$("#product1_total_price").text($("#product1_base_price").val() * $("#number").val());
});
});