Javascript onclick按钮没有';行不通
我尝试单击1按钮,使第一个(空白)按钮中的值为1,但我的代码不起作用,在单击之前,第一个按钮的值变为1 HTML代码Javascript onclick按钮没有';行不通,javascript,html,Javascript,Html,我尝试单击1按钮,使第一个(空白)按钮中的值为1,但我的代码不起作用,在单击之前,第一个按钮的值变为1 HTML代码 <html> <head> <title> Exemplu </title> </script> </head> <body> <form> <input type="button" value="" id= "say_result"
<html>
<head>
<title>
Exemplu
</title>
</script>
</head>
<body>
<form>
<input type="button" value="" id= "say_result"/>
</form>
<form>
<input type="button" value="1" id= "say_one"/>
</form>
<form>
<input type="button" value="2" id= "say_two"/>
</form>
<form>
<input type="button" value="+" id= "say_plus"/>
</form>
<form>
<input type="button" value="-" id= "say_minus"/>
</form>
<form>
<input type="button" value="=" id= "say_equal"/>
</form>
<script type="text/javascript" src=exemplu3.js></script>
</body>
</html>
在以下行中:
oneButton.onclick = cifr(1);
您正在使用参数1
调用cifr
函数,并将结果分配给oneButton
click事件
这可能是:
oneButton.onclick = function(){cifr(1);};
您是否考虑过添加缺少的分号和括号?;)
oneButton.onclick = function(){cifr(1);};