0
我正在为某件事进行测验。在HTML中有一个用户可以输入他们的答案的文本框。我想把它发送给JS来播放一个图像(如果正确的话是'正确的'图像,如果错误的话是'错误'的图像)。这是迄今为止与这个问题有关的代码。将HTML引入JS以播放图像
的Html
<input class="respBox" id="ans1" placeholder="Insert value of X here">
<p id="response1"></p>
<button type="button" class="specialButton" onclick="checkAnswers()">Submit</button>
JS 功能checkAnswers(){
if (ans1 === "7.5") {// If x is 7.5
response1 = rightAns;//rightAns is image for right answer
document.getElementById('response1').innerHTML = response1;//updates scoring system
score++;//adds one point to the user's score
} else {
response1 = wrongAns;//wrongAns is image for wrong answer
document.getElementById('response1').innerHTML = response1;//updates scoring system
}}
我收到此错误信息,当我看到的网站。
遗漏的类型错误:在checkAnswers无法读取空 的特性“值”