我是 javascript 新手,我正在尝试使用 javascript 构建一个计算器。
<form name="calc">
<div class="screen"><input name="output" class="editscreen"></div>
<div class="main-keys">
<button name="del" value="" onClick="rundel()" class="btn2 btn-del">DEL</button>
<button name="7" value="7" onClick="run7()" class="btn2 num">7</button>
<button name="8" value="8" onClick="run8()" class="btn2 num">8</button>
<button name="9" value="9" onClick="run9()" class="btn2 num">9</button>
<button name="ac" value="ac" onClick="runac()" class="btn2 btn-ac">AC</button>
<button name="minus" value="-" onClick="runminus()" class="btn2 btn-minus">-</button>
<button name="4" value="4" onClick="run4()" class="btn2 num">4</button>
<button name="5" value="5" onClick="run5()" class="btn2 num">5</button>
<button name="6" value="6" onClick="run6()" class="btn2 num">6</button>
<button name="multi" value="x" onClick="runmulti()" class="btn2 btn-multi">x</button>
<button name="plus" value="+" onClick="runplus()" class="btn2 btn-plus">+</button>
<button name="1" value="1" onClick="run1()" class="btn2 num">1</button>
<button name="2" value="2" onClick="run2()" class="btn2 num">2</button>
<button name="3" value="3" onClick="run3()" class="btn2 num">3</button>
<button name="div" value="÷" onClick="rundiv()" class="btn2 btn-div">÷</button>
<button name="ans" value="ans" onClick="runans()" class="btn2 btn-ans">ANS</button>
<button name="0" value="0" onClick="run0()" class="btn2 num">0</button>
<button name="dec" value="." onClick="rundec()" class="btn2 num">.</button>
<button name="exp" value="exp" onClick="runexp()" class="btn2 btn-exp">EXP</button>
<button name="eq" value="=" onClick="runeq()" class="btn2 btn-eq">=</button>
</div>
</form>
<script>
function run1()
{document.calc.output.value += "1";}
function run2()
{document.calc.output.value += "2";}
function run3()
{document.calc.output.value += "3";}
function run4()
{document.calc.output.value += "4";}
function run5()
{document.calc.output.value += "5";}
function run6()
{document.calc.output.value += "6";}
function run7()
{document.calc.output.value += "7";}
function run8()
{document.calc.output.value += "8";}
function run9()
{document.calc.output.value += "9";}
function run0()
{document.calc.output.value += "0";}
function rundec()
{document.calc.output.value = ".";}
function runplus()
{document.calc.output.value = "+";}
function runminus()
{document.calc.output.value = "-";}
function rundiv()
{document.calc.output.value = "÷";}
function runmulti()
{document.calc.output.value = "x";}
function rundel()
{document.calc.output.value = "";}
</script>
当我点击任何键时,它只是闪烁,如何解决它。如果有其他方法可以使用 javascript 构建计算器,请帮助我。