我开始使用这个解决方案,但我似乎无法让它工作
这是我的html示例
<table>
<tbody>
<tr id="tr_affiliation_15159">
<td class="right col_aff_amount">15.00</td>
</tr>
<tr id="tr_affiliation_15189">
<td class="right col_aff_amount">15.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td class="total"></td>
</tr>
</tfoot>
</table>
这是我的javascript函数
function removeRow(id) {
$("#tr_affiliation_" + id).fadeOut("slow", function() {
$("#tr_affiliation_" + id).remove();
// recalc total
var total = 0;
$('.col_aff_amount').each(function() {
// i have tried .text(), and .html() as well as .val() but it doesn't seem to make any difference
var val = parseFloat($(this).val());
console.log(val);
total += val;
});
$("td.total").html(parseFloat(total).toFixed(2));
}
我的控制台日志只显示了一长串 NaN,为什么不能提取数字?