JSFiddle - React, Tailwind, and code Playground
HTML
Price:
<input id="price" type="text" />
<table id="my-table">
<tr>
<td>Quantity</td>
<td>Total</td>
</tr>
<tr>
<td class="quantity">15,447.84</td>
<td class="total"></td>
</tr>
<tr>
<td class="quantity">89.28</td>
<td class="total"></td>
</tr>
</table>
JavaScript
$(document).ready(function () {
$('#price').on('change', calTotal);
function calTotal() {
var p = $('#price').val();
$('.total').each(function () {
$(this).text(function () {
var q = $(this).prev().text();
q = q.replace(/,/g, '');
p = p.replace(/,/g, '');
return (parseFloat(p) * parseFloat(q))
});
});
}
});