【发布时间】:2020-05-12 08:53:01
【问题描述】:
我在网上查看了有关我遇到的这个问题的其他情况,但没有一个真正为我提供了关于我希望解决的问题的解决方案。我目前设置了一个按钮,因此如果有人按下它,我希望将符号(在这种情况下为加号)打印到输入框中,但目前,我的代码行没有给我解决方案。 对于我的计算器,我设法用我的数字键盘成功地将其拉下来,但是当涉及到符号时,我不知道发生了什么。当我检查控制台时,每当我按下加号按钮时,它都会给我“未捕获的语法错误:分配中无效的左侧”的错误。
<form name = "clear-console">
<input type = "number" id = "input" placeholder = "0">
<input type = "button" value = "4" onClick = numbers(4) class = "number-pad"></button>
<input type = "button" name = "add" class = "number-pad" value = "+" onclick = "clear-console.display.value += '+'"> //this line of code
</form>
对我的目标有什么解决方案吗?我在代码中遗漏了什么吗? 感谢您的帮助!
【问题讨论】:
-
clear-`应该做什么?console.display是什么? -
@D.Pardal 对不起,'不应该在清除之后-。它应该是“清晰的控制台”。这是我为我的计算器的“全部清除”功能提供的表格名称。
-
哦,函数名不能包含
-。那是你的问题。也许你的意思是_。
标签: javascript html css