在我必须做的一件简单的事情中,赋值中的左侧无效
Invalid left-hand side in assignment in a simple thing I have to do
因此,在为该代码赋值时,我在第12行(var声明所在的位置)得到错误Invalid left side:
<html>
<head>Guessing Game</head>
<body>
<p>"Hello! Welcome to the Guessing Game of Life or Slavery. Remember to use correct spelling and punctuation!"</p>
<form id ="q1" action = "">
"What is the meaning of life the universe and everything?"
<input type = "text" >
</form>
<script>
var answerOne = function(){
var theAnswer = "42"
if("text" == theAnswer){
prompt("TEST!")
}
}
</script>
</body>
</html>
我只是测试一下。。。我真正想做的是制作一个网页,在那里我回答了这个问题,上面写着"你就在网页上
这就是你需要的吗?:
<script>
function answerOne(){
var theAnswer = "42"
var answerGiven= document.getElementById('answer').value;
if(answerGiven == theAnswer){
//code for correct answer
alert("correct");
}
else {
//code for incorrect answer
alert("incorrect");
}
}
</script>
</head>
<body>
<p>"Hello! Welcome to the Guessing Game of Life or Slavery. Remember to use correct spelling and punctuation!"</p>
<form id ="q1" action = "" onsubmit="answerswerOne();" >
"What is the meaning of life the universe and everything?"
<input type = "text" id="answerswer">
<input type="submit" value="Submit" >
</form>
注意:表单验证未完成,需要在用户输入任何无效值时进行
相关文章:
- 未捕获的ReferenceError:赋值中的左侧无效
- 变量赋值无效
- Javascript/Html 未捕获的引用错误:赋值中的左侧无效;未捕获的引用错误:未定义计算
- 样式属性赋值上的“赋值中的左侧无效”
- 左侧赋值无效(railo.transformer.bytecode.op.OpString)
- 在javascript中构建HTML表,得到“引用错误:左侧无效赋值”
- 更改 CSS“z-index”属性:“赋值中的左侧无效”
- Javascript 错误:左侧赋值无效
- 在引用错误中将字符串放在一起:左侧的赋值无效
- 未捕获的引用错误:赋值(匿名函数)中的左侧无效
- jQuery/Javascript赋值左侧无效
- 为innerHTML赋值无效
- 带有三进制if的左侧赋值无效
- 在我必须做的一件简单的事情中,赋值中的左侧无效
- "赋值中的左侧无效“;当接收到来自Facebook API的响应时
- 我得到了“;赋值中的左侧无效“;在我的代码(JS)中
- 变量名称-赋值中左侧无效
- 未捕获的ReferenceError:赋值javascript中的左侧无效
- 如何处理'无效赋值left hand '错误:firefox或chrome
- 如果第一个条件为true,则在javascript中为变量赋值,引用错误左侧赋值无效