![在这里插入图片描述](https://img-blog.csdnimg.cn/20181206143034504.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM4MzM1Mjk1,size_16,color_FFFFFF,t_70)
<html>
<head>
<title>每日一练之计算器</title>
<meta charset="utf-8"/>
</head>
<style type="text/css">
#showdiv{
margin:auto;
margin-top: 100px;
border:1px solid;
width:300px;
border-radius: 10px;
background-color: whitesmoke;
}
input[type=text]{
width:280px;
height:40px;
margin-left: 10px;
margin-top: 10px;
}
input[type=button]{
width:60px;
height:60px;
margin-top: 10px;
margin-left:10px;
margin-bottom: 10px;
font-size:30px;
}
</style>
<script type="text/javascript">
function Counting(obj){
var text = document.getElementById("tet");
switch(obj.value){
case "C":
text.value="";
break;
case "=":
text.value=eval(text.value);
break;
default:
text.value=text.value+obj.value;
break;
}
}
</script>
<body>
<div id="showdiv">
<input type="text" name="" id="tet" value="" /><br/>
<input type="button" name="" id="" value="0" onclick="Counting(this)"/>
<input type="button" name="" id="" value="1" onclick="Counting(this)"/>
<input type ="button" name="" id="" value="2" onclick="Counting(this)"/>
<input type="button" name="" id="" value="3" onclick="Counting(this)"/><br/>
<input type="button" name="" id="" value="4" onclick="Counting(this)"/>
<input type="button" name="" id="" value="5" onclick="Counting(this)"/>
<input type="button" name="" id="" value="6" onclick="Counting(this)"/>
<input type="button" name="" id="" value="7" onclick="Counting(this)"/><br/>
<input type="button" name="" id="" value="8" onclick="Counting(this)"/>
<input type="button" name="" id="" value="9" onclick="Counting(this)">
<input type="button" name="" id="" value="+" onclick="Counting(this)"/>
<input type="button" name="" id="" value="-" onclick="Counting(this)"/><br/>
<input type="button" name="" id="" value="*" onclick="Counting(this)"/ >
<input type="button" name="" id="" value="/" onclick="Counting(this)"/>
<input type="button" name="" id="" value="C" onclick="Counting(this)"/>
<input type="button" name="" id="" value="=" onclick="Counting(this)"/>
</div>
</body>
日记式之Html5之计算器(2018.12.5)
猜你喜欢
转载自blog.csdn.net/qq_38335295/article/details/84853170
今日推荐
周排行