<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>计算器</title>
<script type="text/javascript" src="./js/jquery-1.9.1.min.js"></script>
<script>
function tianjia1(){
$("#black").append($("#t1").html());
}
function tianjia2(){
$("#black").append($("#t2").html());
}
function tianjia3(){
$("#black").append($("#t3").html());
}
function tianjia4(){
$("#black").append($("#t4").html());
}
function tianjia5(){
$("#black").append($("#t5").html());
}
function tianjia6(){
$("#black").append($("#t6").html());
}
function tianjia7(){
$("#black").append($("#t7").html());
}
function tianjia8(){
$("#black").append($("#t8").html());
}
function tianjia9(){
$("#black").append($("#t9").html());
}
function tianjia0(){
$("#black").append($("#t0").html());
}
function tianjiaadd(){
$("#black").append($("#add").html());
}
function tianjiadian(){
$("#black").append($("#10").html());
}
function tianjiaj(){
$("#black").append($("#jian").html());
}
function tianjiac(){
$("#black").append($("#cheng").html());
}
function tianjiachu(){
$("#black").append($("#chu").html());
}
function equal(){
var ht = $("#black").text();
var v = eval(ht);
$("#black").html(v);
}
function ac(){
$("#black").html("");
}
</script>
</head>
<body>
<table border="1" cellspacing="0" style="width: 500px; height: 300px; text-align: center; font-weight: bold;">
<tr>
<td colspan="4" style="font-family: 黑体; font-size: 36px; color: aqua;">计算器</td>
</tr>
<tr>
<td id="AC" οnclick="ac()">AC</td>
<td id="black" colspan="3" style="text-align: center;"></td>
</tr>
<tr>
<td id="t1" οnclick="tianjia1()">1</td>
<td id="t2" οnclick="tianjia2()">2</td>
<td id="t3" οnclick="tianjia3()">3</td>
<td id="add" οnclick="tianjiaadd()">+</td>
</tr>
<tr>
<td id="t4" οnclick="tianjia4()">4</td>
<td id="t5" οnclick="tianjia5()">5</td>
<td id="t6" οnclick="tianjia6()">6</td>
<td id="jian" οnclick="tianjiaj()">-</td>
</tr>
<tr>
<td id="t7" οnclick="tianjia7()">7</td>
<td id="t8" οnclick="tianjia8()">8</td>
<td id="t9" οnclick="tianjia9()">9</td>
<td id="cheng" οnclick="tianjiac()">*</td>
</tr>
<tr>
<td id="t0" οnclick="tianjia0()">0</td>
<td id="10" οnclick="tianjiadian()">.</td>
<td id="equal" οnclick="equal()">=</td>
<td id="chu" οnclick="tianjiachu()">/</td>
</tr>
</table>
</body>
</html>
JQuery计算器
最新推荐文章于 2024-09-07 08:14:00 发布