JS - 检查输入字段是否等于解决方案 [英] JS - Check if the input field equals the solution
本文介绍了JS - 检查输入字段是否等于解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为有数学问题的小孩制作一个简单的网站,
I'm making a simple website for little kids with mathproblems,
该页面包含了孩子们需要解决的一些问题。他们可以按1按钮检查他们输入的值是否与解决方案相同。 JAVASCRIPT是有义务的
the page contains a number of questions that the kids need to solve. They can press on 1 button that checks if the value that they inputted, equal is to the solution. JAVASCRIPT is obligated
我在HTML中有这个:
I have this in HTML:
Question 1: how much is 8 x 4?
<br><input type="text"> <br>
<button onclick="question1()">Check if your answer is correct?</button>
我的功能已经有了这个,但我似乎无法用我的语法作出决定看起来正确:
my function already has this, but i can't seem to make up my mind with the syntax that looks correct:
function question1() {
if (value == 32) {
window.alert("correct!");
} else {
window.alert("try again);
}
}
但我的语法看起来正确吗?
but my syntax looks correct?
推荐答案
window.alert( 再试一次);
需要 window.alert(再试一次);
你忘记发表报价
这篇关于JS - 检查输入字段是否等于解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文