JSFiddle - React, Tailwind, and code Playground

by Nick Craver

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<table>
    <tr>
        <td><input type="text" class="qty" value="0" /></td>
        <td><input type="text" class="qty" value="0" /></td>
        <td><input type="text" class="qty" value="0" /></td>
        <td><input type="text" id="total" value="0" /></td>
    </tr>
</table>

JavaScript

$('input.qty').change(function() {
  var sum = 0;
  $('input.qty').each(function() { sum += parseInt(this.value, 10); });
  $('#total').val(sum);
});