每当输入框改变时,我都试图通过id在页面的其他地方显示数字用户输入,但它不起作用。这是我一直在使用的
function updateTotalCashPaid() {
var x;
var cashInput = document.getElementById("cashPaid").value;
x = cashInput;
document.getElementbyId("totalCashPaid").innerHTML = x;
}
<p style="padding-left:10%"><input type="Number" id="cashPaid" name="cashPaid" step=".01" min="0" onchange="updateTotalCashPaid()"></p>
<p id="totalCashPaid" style="display: inline; ">replace with User Input</p>
有谁看到我做错了什么?
答案 0 :(得分:1)
我看到一个简单的拼写错误。您需要getElementById
getElementbyId
,而不是document.getElementbyId("totalCashPaid").innerHTML = x;