JSFiddle - React, Tailwind, and code Playground
HTML
<div>
Qtde_entrada: <input type="text" id="qtde_entrada">
Qtde_falta: <input type="text" id="qtde_falta">
</div>
<table>
</table>
<button id="new_fields">
New Fields
</button>
JavaScript
function calc() {
if ($(this).val().length > 0) {
var total = 0;
$('.input').each(function() {
var valor = Number($(this).val());
if (!isNaN(valor)) total += valor;
});
var final = $("#qtde_entrada").val() - total;
$("#qtde_falta").val(final);
}
}
$(function() {
var $table = $('table');
$("#new_fields").on('click', function() {
$table.append('<tr><td><input type="text" class="input"></td></tr>');
})
$table.on('change', '.input', calc);
$("#qtde_entrada").on('change', calc);
});