mez*_*tli -1 javascript calculator onclick
我是Javascript的新手,我按照一个简单的教程来创建一个新手计算器,但我无法让它工作,不明白为什么不.
它应该在警告框中显示结果,而不是.
任何帮助/输入都非常感谢,
谢谢
<script type="text/javascript">
var a,b, result;
funciton setValues()
{
a = Number(document.getElementById("a").value);
b = Number(document.getElementById("b").value);
}
function sum() {
setValues();
result = a+b;
alert("The sume is equel to "+result);
}
function rest()
{
setValues();
result = a-b;
alert("The result is equal to "+result);
}
function mult()
{
setValues();
result = a*b;
alert ("The result is equal to "+result);
}
function div()
{
setValues();
result = a/b;
alert ("The result is equal to "+result);
}
</script>
</head>
<body>
<div>
<input id="a" type="text"/>
<input id="b" type="text"/>
<button type="button" onclick="sum()">+</button>
<button type="button" onclick="rest()">-</button>
<button type="button" onclick="mult()"> *</button>
<button type="button" onclick="div()"> /</button>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
拼写功能在funciton setValues()不正确.
此外,onclick的拼写错误.
Line 39:<button type="button" onlcick="sum()">+</button>
Run Code Online (Sandbox Code Playgroud)
这是唯一的错误,其余的代码是完美的.
| 归档时间: |
|
| 查看次数: |
140 次 |
| 最近记录: |