<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>My JSP ‘JqueryTest.jsp‘ starting page</title>
<script src="JqueryTest/jquery-1.3.2.min.js"></script>
<style>
td{width:30;height:30;text-align:center;border:1;border-style:solid;border-color:#000;}
</style>
<script>
window.onload=function(){
var $tds=$(‘td:gt(0)[class!=equal][class!=clear]‘);
$tds.click(function(){
var display=$(‘.screen‘).html();
$(‘.screen‘).html(display+this.innerHTML);//$(‘this‘).html();//html()里面空则为读,不为空则为写入
});
$(‘.clear‘).click(function(){
$(‘.screen‘).html("");
});
$(‘.equal‘).click(function(){
var display=$(‘.screen‘).html();
var value=eval(display);//eval进行逻辑运算
$(‘.screen‘).html(display+"="+value);
});
}
</script>
</head>
<body>
<table>
<tr><td colspan=4 class="screen"></td></tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>*</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
<td>/</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
<td>+</td>
</tr>
<tr>
<td>.</td>
<td class="clear">c</td>
<td class="equal">=</td>
<td>-</td>
</tr>
</table>
</body>
</html>