我正在尝试使用 JS 完成刽子手任务。我正在尝试完成,function processGuess(event)以便我可以在控制台上运行程序并在我的其余代码中识别任何错误。当我运行游戏时,我可以输入一个单词让另一个玩家猜测,但是当我“猜测”一个字母时,控制台上会出现一个错误:
script.js:63 未捕获的类型错误:无法读取 HTMLElement.processGuess (script.js:63) 处未定义的属性“toUpperCase”。
我不确定为什么会这样。错误所引用的行是:
document.getElementById("hangman").value.toUpperCase();
html代码:
<!DOCTYPE html>
<html>
<head>
<title>Hangman!</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<section id ="gallows">
<p>section for picture of hanged man</p>
<img id="gallowsimg" src="images/strike-0.png" alt="gallows">
</section>
<section id ="strikes">
<p>strikes section shows incorrect guesses</p>
<div id ="strikeLetters">
<p>
</p>
</div>
</section>
<section id ="correctword">
<div id ="guessword">
</div>
<p>word section that shows the word being guessed correctly</p>
</section>
<section id ="guess-form">
<p>guess section that contains form where player can type in a letter to guess</p>
<form id="hangman">
<input type="text" name="letter" id="letter" placeholder="Guess a letter" />
<input id="guess" name="guess" type="submit" value="Guess" />
</form>
</section>
</body>
</html>
慕容708150
qq_花开花谢_0
相关分类