我正在为分配计算器编程,并且正在努力将每个按钮单击的值附加到我的显示框。例如,如果我单击按钮“ 4”,然后单击“ 5”,则我希望显示器输出“ 45”,依此类推,以便评估显示框中的内容。当我单击计算器上的一个按钮时,该数字将正确显示,但是此后不会再添加任何并发值。如果在键盘上键入显示,我还创建了equal函数以正确运行。
<!DOCTYPE html>
<head>
<link href="project4.css" rel="stylesheet">
<title>Calculator</title>
</head>
<body>
<div id="calculator">
<h3>Calculator</h3>
<input type="text" id="display" onClick= "append()"><br />
<input type="button" value="mrc" class="memory">
<input type="button" value="m+" class="memory">
<input type="button" value="m-" class="memory">
<input type="button" value="/" class="operator" onClick= "setDivide()"><br />
<input type="button" value="7" class="number" onClick= "setSeven()">
<input type="button" value="8" class="number" onClick= "setEight()">
<input type="button" value="9" class="number" onClick= "setNine()">
<input type="button" value="*" class="operator" onClick= "setMultiply()"><br />
<input type="button" value="4" class="number" onClick= "setFour()">
<input type="button" value="5" class="number" onClick= "setFive()">
<input type="button" value="6" class="number" onClick= "setSix()">
<input type="button" value="+" class="operator" onClick="setAdd()"><br />
<input type="button" value="1" class="number" onClick= "setOne()">
<input type="button" value="2" class="number" onClick= "setTwo()">
<input type="button" value="3" class="number" onClick= "setThree()">
<input type="button" value="-" class="operator" onClick= "setSubtract()"><br />
<input type="button" value="0" class="number" onClick= "setZero()">
<input type="button" value="." value="." class="number" onClick= "setDecimal()">
<input type="button" value="C" class="clear" onClick= "setClear()">
<input type="button" value="=" class="equal" onClick= "setEquals()">
</div>
九州编程
相关分类