I have the following table
<table class="table table-hover table-secondary mt-1 table-responsive">
<thead>
<tr>
<th>Producto</th>
<th>Cantidad</th>
<th>Sub Total Efectivo</th>
<th>Sub Total Tarjeta</th>
</tr>
</thead>
<tbody id="CarroDeCompra">
<tr>
<td>Nombre</td>
<td>Cantidad</td>
<td>Efectivo</td>
<td>Tarjeta</td>
</tr>
</tbody>
</table>
What I want is to count the amounts in the second column, which says quantity.
I searched the Internet and found this code, but it would not be working:
function ContarProductos() {
let cantidad =0;
('#CarroDeCompra td').find('td:eq(1)').each(function() {
//obtenemos el valor de la celda
valor = $(this).html();
//sumamos, recordar parsear, si no se concatenara.
cantidad += parseInt(valor)
});
return cantidad;
}
Can anyone give me any advice? Thank you very much from now!