當我輸入一些數字時,它不顯示任何數字。我試圖在我的site上插入此代碼,但無法正常工作。請幫我java腳本錯誤拋出異常
function myFunction() {
var message, x;
message = document.getElementBy("message");
message.innerHTML = "";
x = document.getElementById("demo").value;
try {
if(x == "") throw "empty";
if(isNaN(x)) throw "not a number";
x = Number(x);
if(x < 5) throw "too low";
if(x > 10) throw "too high";
}
catch(err) {
message.innerHTML = "Input is " + err;
}
}
<p>Please input a number between 5 and 10:</p>
<input id="demo" type="text">
<button type="button" onclick="myFunction()">Test Input</button>
<p id="message"></p>
'消息= document.getElementBy' ......什麼?投票結束爲錯字。 –
什麼是錯誤 –
錯誤消息說明了所有'Uncaught TypeError:document.getElementBy不是一個函數' – Jamiec