# 简单计算器

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.zy{
height: 170px;
width: 300px;
margin: 0px auto;

/* border:1px #222222 solid;*/
}
.zy1{
height: 15px;
width: 275px;
margin-top: 15px;
}
.fk{
height: 15px;
width: 75px;
float: left;
}
.fk1{
height: 15px;
width: 200px;
float: left;
}
.fk2{
height: 15px;
width: 275px;
float: left;
}
p{
alige="senter";
}
</style>
<script type="text/javascript">
function fuhao(yunsuan){
var one=document.getElementById("first");
var two=document.getElementById("second");
var three=document.getElementById("third");
if(yunsuan=="jia"){
three.value=Number(one.value)+Number(two.value);
}else if(yunsuan=="jian"){
three.value=Number(one.value)-Number(two.value);
}else if(yunsuan=="cheng"){
three.value=Number(one.value)*Number(two.value);
}else if(yunsuan=="chu"){
three.value=Number(one.value)/Number(two.value);
}
}
</script>
<body>

<div class="zy">
<div><p align="center">计算机</p></div>

<div class="zy1">
<div class="fk">
第一个数
</div>
<div class="fk1">
<input type="text"  id="first">
<input type="submit"  value="+" id="jia" onclick="fuhao(this.id)"
</div>
</div>
<hr>
<div class="zy1">
<div class="fk">
第二个数
</div>
<div class="fk1">
<input type="text"  id="second">
<input type="submit"  value="-" id="jian" onclick="fuhao(this.id)">
</div>
</div>
<hr>
<div class="zy1">
<div class="fk">
结果
</div>
<div class="fk1">
<input type="text"  id="third">
<input type="submit"  value="*" id="cheng" onclick="fuhao(this.id)">
</div>
</div>
<hr>
<div class="zy1">
<div class="fk2">
运算方法：先两个数再选择算法
<input type="submit"  value="/" id="chu" onclick="fuhao(this.id)">
</div>
</div>
<hr>
</div>
</body>
</html>
• 本文已收录于以下专栏：

举报原因： 您举报文章：简单计算器 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)