<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>计算器</title>
<style type="text/css">
.main{
width: 200px;
height: 200px;
margin: auto;
border: solid;
}
#div1{
margin-left: 20px;
margin-top: 20px;
background-color: #34B4C6;
border: solid 0px;
}
#div2{
margin-left: 20px;
margin-top: 20px;
background-color: #34B4C6;
border: solid 0px;
}
#div3{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
margin-top: 20px;
}
#div4{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
}
#div5{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
margin-top: 20px;
}
#div6{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
}
</style>
<script type="text/javascript">
function jia () {
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1+a2;
alert(a3);
}
function cheng(){
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1*a2;
alert(a3);
}
function jian(){
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1-a2;
alert(a3);
}
function chu(){
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1/a2;
alert(a3);
}
</script>
</head>
<body>
<div class="main">
<input id="div1" type="text" value="请输入一个数">
<input id="div2" type="text" value="请输入一个数">
<input id="div3" type="button" value="+" οnclick="jia()">
<input id="div4" type="button" value="*" οnclick="cheng()">
<input id="div5" type="button" value="-" οnclick="jian()">
<input id="div6" type="button" value="/" οnclick="chu()">
</div>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>计算器</title>
<style type="text/css">
.main{
width: 200px;
height: 200px;
margin: auto;
border: solid;
}
#div1{
margin-left: 20px;
margin-top: 20px;
background-color: #34B4C6;
border: solid 0px;
}
#div2{
margin-left: 20px;
margin-top: 20px;
background-color: #34B4C6;
border: solid 0px;
}
#div3{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
margin-top: 20px;
}
#div4{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
}
#div5{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
margin-top: 20px;
}
#div6{
width: 40px;
height: 40px;
font-size: 30px;
font-weight: bolder;
background-color: #FF6287;
margin-left: 30px;
}
</style>
<script type="text/javascript">
function jia () {
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1+a2;
alert(a3);
}
function cheng(){
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1*a2;
alert(a3);
}
function jian(){
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1-a2;
alert(a3);
}
function chu(){
var a1,a2,a3;
a1=document.getElementById("div1").value;
a2=document.getElementById("div2").value;
a1=Number(a1);
a2=Number(a2);
a3=a1/a2;
alert(a3);
}
</script>
</head>
<body>
<div class="main">
<input id="div1" type="text" value="请输入一个数">
<input id="div2" type="text" value="请输入一个数">
<input id="div3" type="button" value="+" οnclick="jia()">
<input id="div4" type="button" value="*" οnclick="cheng()">
<input id="div5" type="button" value="-" οnclick="jian()">
<input id="div6" type="button" value="/" οnclick="chu()">
</div>
</body>
</html>