i have jquery script with operator minus, but i got wrong values, this is my code
var fuid = $(this).attr("data-delete-id");
var hargaProduk = parseInt($("#harga_"+fuid).text());
var hargaTotal = parseInt($("#total-harga").text());
var newValue = hargaTotal - hargaProduk;
$("#total-harga").html(newValue);
And this is my HTML Code
// foreach in here
<tr id="table_1">
<td>Data 1</td>
<td>Rp <span id="harga_1"> 275,000</span></td>
<td><span class="delete-product" data-delete-id="1"><span>Delete</span></span></td>
</tr>
<tr id="table_2">
<td>Data 2</td>
<td>Rp <span id="harga_2"> 175,000</span></td>
<td><span class="delete-product" data-delete-id="2"><span>Delete</span></span></td>
</tr>
<tr id="table_3">
<td>Data 3</td>
<td>Rp <span id="harga_3"> 180,000</span></td>
<td><span class="delete-product" data-delete-id="3"><span>Delete</span></span></td>
</tr>
//end foreach in here
<tr style="background:#DEDEDE;">
<td><b>Total </b></td>
<td></td>
<td><b>Rp <span id="total-harga"><?= number_format(CartTotal())?></span></b></td>
<td></td>
</tr>
When i run it, it displaying like this:
But when i click delete in number 3 and run JS script value change to Rp -179
Is there something wrong with my code? i just want to display value from variable hargaTotal - hargaProduk
Thankyou