How to use jQuery to find balance from Debit and Credit in Django row table

  django, jquery, python

Please help, i have my Django app where i have row table where fetch numbers from database and it work correctly, i have one problem i want to calculate balance by taking balance plus debit side and minus credit side by using jquery but refer what i get in a link plus what i expect.
Note: I failed to use django itself because balance doesn`t saved to database

What i get: []

Expected: []


< script >
  $(document).ready(function() {
    $('tr').each(function() {
      var balance = [];
      $(this).find('#col1').each(function() {
        var bal = $(this).text();
        if (bal.length !== 0) {
          var bala = $("#balance").text();
          balance = bal + bala
      $(this).find('#col2').each(function() {
        var bal = $(this).text();
        if (bal.length !== 0) {
          var bala = $("#balance").text();
          balance = bala - bal
  }); <


<script src=""></script>
  {% for statement in customer_stat %}
  <tr style="margin-top: 20px; font-size: 25px; margin-left: 90px;">
    <td class="col" id="col1">{{statement.total_amount}}</td>
    <td class="col" id="col2">{{statement.to_amount}}</td>
    <td id="balance"></td>
  {% endfor %}


Source: Python Questions