{
var a = document . getelementbyid(" test input ")。價值;//獲取文本框的值
如果(法蘭& amp& ampoper!= " = " { }//運算符不為=時不執行任何操作
Else //點擊時=
{
flang = true
If('+'==oper) //運算符為+。
{
total = parse float(total)+pares float(a);//最後保存的值加上文本框的值,總和應該就是我上壹個問題解釋的那個。
}
Else if('-'==oper){ //後跟-*/同裏
total-= a;
}
else if('*'==oper){
total * = a;
}
else if('/'==oper){
total/= a;
}
其他
{
總計= a;
}
document . getelementbyid(" test input ")。值=總計;//然後將運算結果放入文本框。
oper = v;//運算符標誌重新分配
}
}
整個方法就是當妳點擊=,最後保存的輸入值(理解為被除數被減等等)和第二個輸入值進行運算。