JSFiddle - React, Tailwind, and code Playground

HTML

<input class="test" type="text" rel="90" alt="30.00">
<div id="t_balance"></div>
<input type="text" id="discount" />

JavaScript

function onCheck() {
    var t_balance = 0;
    $(".test").each(function() {
        $(this).attr("alt");
    });
    $("#t_balance").html(t_balance.toFixed(2));
    
    calculateSum();
}

function calculateSum() {
    var sum = parseFloat( $("#t_balance").text() );
    
    $(":text").each(function() {
        if (!isNaN(this.value) && this.value.length != 0) {
            sum -= parseFloat(this.value);
        }
    });
    $("#t_balance").html(sum.toFixed(2));
}

$(".test").change(onCheck);
$(":text").keyup(onCheck);