原生JS實現簡易計算器 逆戰班

2021-10-03 04:14:27 字數 1078 閱讀 6197

**

基本功能:實現加減乘除的運算

具體**如下:

html

)ce

ac 789

/ 456

x 123

- 0.=

+

css

.calculator 

.calculator .c_screen

.calculator .c_screen>p

.calculator .c_row

button

button::selection

button:active

.c_func_btn

js

content = document.getelementsbytagname('p')[0], // 顯示器內容

count = 0, //記錄顯示屏上字元及數字個數

bonedec = false; //表示顯示屏乙個數字中是否已經有乙個小數點的狀態

btn_wrap.onclick = function(e)

if(btntype == 'ac')else if(btntype == 'ce')else

count--;

}}else if(btntype == '=')else

}content.innertext = result;

count = result.length;

}catch(e)

}}else

if(btntype == '.')

bonedec = true;

}if(content.innertext == '0' && (!isnan(+btntype) ||

btntype == '(' || btntype == ')'))

content.innertext += btntype;

if(count++ >= 44)

}

}}

實現簡易計算器

python 剛學python 老師帶著寫了乙個計算器。話不多說直接上 from tkinter import 匯入模組 top tk 設定視窗物件 top.title 計算器 設定視窗標題 v strin ar 接受使用者輸入的字元 v.set 0 設定字元預設值 isopera false 是否...

計算器簡易實現

testdlg.cpp 實現檔案 include stdafx.h include include test.h include testdlg.h include afxdialogex.h ifdef debug define new debug new endif define tag add...

簡易計算器(Java實現)

本文參考自侵刪。一.ui介面的布置 窗體中放置三個jpanel面板,第乙個面板放數字與操作符元件 0 9,4 4網格布局,置於窗體中部 第二個面板放文字框,置於頂部 第三個面板放 清空 按鈕與 歷史記錄 按鈕,置於底部。窗體為邊界布局。按鈕上的數字 操作符使用陣列儲存,乙個for迴圈就能建立完按鈕並...