Html
    Css
    Js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<div id="a">
<div id="b">
<input type="text" name="" id="answer" readonly="readonly"><br>
<input type="text" name="" id="answer2" readonly="readonly">
</div>
<div id="c">
<input type="button" name="" id="fs1" value="C" onclick="clean()">
<input type="button" name="" id="fs2" value="<" onclick="del()">
<input type="button" name="" id="fs3" value="+" onclick="jia()">
<input type="button" name="" id="fs4" value="-" onclick="jian()">
</div>
<div id="d">
<input type="button" value="7" id="bs1" onclick="press(7)">
<input type="button" value="8" id="bs2" onclick="press(8)">
<input type="button" value="9" id="bs3" onclick="press(9)">
<input type="button" name="" id="fs5" value="x" onclick="cheng()">
</div>
<div id="e">
<input type="button" name="" id="bs4" value="4" onclick="press(4)">
<input type="button" name="" id="bs5" value="5" onclick="press(5)">
<input type="button" name="" id="bs6" value="6" onclick="press(6)">
<input type="button" name="" id="fs6" value="÷" onclick="chu()">
</div>
<div id="f">
<input type="button" name="" id="bs7" value="1" onclick="press(1)">
<input type="button" name="" id="bs8" value="2" onclick="press(2)">
<input type="button" name="" id="bs9" value="3" onclick="press(3)">
<input type="button" name="" id="fs7" value="%" onclick="pressbf()">
</div>
<div id="g">
<input type="button" name="" id="fs8" value="+/-" onclick="jj()">
<input type="button" name="" id="bs10" value="0" onclick="presszero()">
<input type="button" name="" id="fs9" value="." onclick="pressdian()">
<input type="button" name="" id="fs10" value="" onclick="dy()">
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
body {
margin:0;
padding:0;
}
#a {
width:260px;
background-color:#fff;
margin:20px auto;
text-align:center;
border:aquamarine 1px solid;
border-radius:90px;
}
#b #answer,#answer2 {
margin-top:20px;
font-size:14px;
background:transparent;
height:30px;
width:190px;
border:#fff solid 1px;
outline:none;
}
#c input {
padding:10px;
margin:3px;
width:40px;
height:40px;
outline:none;
}
#d input {
padding:10px;
margin:3px;
width:40px;
height:40px;
outline:none;
}
#e input {
padding:10px;
margin:3px;
width:40px;
height:40px;
outline:none;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// str answer answer2
function dy() {
if (str.substr(str.length - 1, 1) == "+" || str.substr(str.length - 1, 1) == "*" || str.substr(str.length - 1, 1) == "-" || str.substr(str.length - 1, 1) == "/") {
str = str.substring(0, str.length - 1);
answer2.value = Number(eval(str));
str = answer2.value;
answer.value = str;
answer2.value = "";
} else {
str = answer2.value;
answer.value = str;
answer2.value = "";
}
//
}
function clean() {
// c
str = "";
answer.value = str;
answer2.value = str;
}
function jj() {
if (answer2.value != "") {
if (answer2.value > 0)
answer2.value = "-" + eval(str);
else {
str = answer2.value;
str = str.substr(1, str.length - 1);
answer2.value = str;
}
}
}
var str = "";
//
function chu() {
if (str === "") {
answer2.value = "";
} else {
// 使
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
↑上面代码改变,会自动显示代码结果 jQuery调用版本:1.11.3
 立即下载

JS计算器(原创)

更新时间:2020-03-17 00:24:56

2
      程序员灬顾琪琪0
      2020/9/17 15:11:00
      我家的猫咪叫英俊0
      2020/7/3 15:51:29
      任何数*0=任何数 吗? 回复