[英]Getting value from text input using document.getElementByID not working
我正在用javascript做一個簡單的項目,它要求我用javascript從HTML文本輸入中獲取值。 在下面的代碼中,我發現在第6行之后沒有任何工作,我不知道為什么。 這讓我瘋狂了兩個小時,我有點在我的智慧結束。 請幫忙!
function letsPlayAGame() {
var answer = Math.floor(Math.random() * 100 + 1);
var guess = document.getElementByID("theinput").value;
if (Number.isInteger(guess) == false) {
document.getElementByID("label").innerHTML =
"Please enter a number between 1 and 100!";
} else if (guess < 1 || guess > 100) {
document.getElementByID("label").innerHTML =
"Please enter a number between 1 and 100!";
} else {
alert("not this part");
}
}
它應該是:
document.getElementById
代替
document.getElementByID
因為Javascript區分大小寫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.