我收到以下错误,但找不到原因:
TypeError:对象不是函数
这是我的html:
<td><input type="text" value="" id="cash_retained" name="cash_retained" onkeyup="net_cash()" size="25"></td>
<td><input type="text" value="" id="cash_change" name="cash_change" onkeyup="net_cash()" size="25"></td>
<td><input type="text" value="0" id="net_cash" name="net_cash"></td>
这是我的js函数:
function net_cash() {
var cash = 0;
var retained = document.getElementById("cash_retained");
var change = document.getElementById("cash_change");
cash += parseInt(retained.value);
cash += parseInt(change.value);
if (isNaN(cash)) {
document.getElementById("net_cash").value = "0";
} else {
document.getElementById("net_cash").value = cash;
}
}
我一生都看不到为什么这不起作用。我有其他类似的 js 函数发现它很好。