JSFiddle - React, Tailwind, and code Playground

by gmcalab

HTML

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

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

JavaScript

$('#totalbtn').click(function() {
    var total = 0;
    $('td.subtotal', '#stock-hotdogs').each(function() {
        total += parseFloat( $(this).text().replace(/[^\d\.]+/g, ''));
    });
    alert(total);
});