如何使用javascript计算sin,cos,tan和数学运算。我想用div(而不是按钮和输入标签)制作一个计算器。我怎么能用它计算。
我的代码是......
<div id="calc">
<input id="screen"></div>
<div id="subkeys">
<div class="btn1">log</div>
<div class="btn1">ln</div>
<div class="btn1">(-)</div>
<div class="btn1">sin</div>
<div class="btn1">cos</div>
<div class="btn1">tan</div>
<div class="btn1">sin<sup>-1</sup></div>
<div class="btn1">cos<sup>-1</sup></div>
<div class="btn1">tan<sup>-1</sup></div>
</div>
<div id="mainkeys">
<div name="del" value="" onClick="rundel()" class="btn2 btn-del">DEL</div>
<div name="7" value="7" onClick="addDigit(7)" class="btn2 num">7</div>
<div name="8" value="8" onClick="addDigit(8)" class="btn2 num">8</div>
<div name="9" value="9" onClick="addDigit(9)" class="btn2 num">9</div>
<div name="ac" value="ac" onClick="runac()" class="btn2 btn-ac">AC</div>
<div name="minus" value="-" onClick="runminus()" class="btn2 btn-minus">-</div>
<div name="4" value="4" onClick="addDigit(4)" class="btn2 num">4</div>
<div name="5" value="5" onClick="addDigit(5)" class="btn2 num">5</div>
<div name="6" value="6" onClick="addDigit(6)" class="btn2 num">6</div>
<div name="multi" value="x" onClick="runmulti()" class="btn2 btn-multi">x</div>
<div name="plus" value="+" onClick="runplus()" class="btn2 btn-plus">+</div>
<div name="1" value="1" onClick="addDigit(1)" class="btn2 num">1</div>
<div name="2" value="2" onClick="addDigit(2)" class="btn2 num">2</div>
<div name="3" value="3" onClick="addDigit(3)" class="btn2 num">3</div>
<div name="div" value="÷" onClick="rundiv()" class="btn2 btn-div">÷</div>
<div name="ans" value="ans" onClick="runans()" class="btn2 btn-ans">ANS</div>
<div name="0" value="0" onClick="addDigit(0)" class="btn2 num">0</div>
<div name="dec" value="." onClick="rundec()" class="btn2 num">.</div>
<div name="exp" value="exp" onClick="runexp()" class="btn2 btn-exp">EXP</div>
<div name="eq" value="=" onClick="runeq()" class="btn2 btn-eq">=</div>
</div>