JSFiddle - React, Tailwind, and code Playground

by gmcalab

HTML

<table id="stock-hotdogs">
    <tr>
        <td>Column</td>
        <td class="subtotal"><input type="text" value="$1.99"/></td>
    </tr>   
    <tr>
        <td>Column</td>
        <td class="subtotal"><input type="text" value="$2.32"/></td>
    </tr>   
</table>

<input type="button" value="Total" id="totalbtn"/>

JavaScript

$('#totalbtn').click(function() {
    var inputs = $('td.subtotal', '#stock-hotdogs').find('input');

    var total = 0;

    $(inputs).each(function() {
        total += parseFloat( $(this).val().replace(/[^\d\.]+/g, ''));
    });
    alert(total);
});