<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>表格定位</title>
<style media="screen">
td{
width:50px;
height:50px;
}
</style>
<script src="./jquery-1.8.3.min.js" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function(){
var trs = $(‘tr‘);
for(var i=0;i<trs.length;i++){
var row = ‘第‘+(i+1)+‘行‘;
for(var j=0;j<trs[i].children.length;j++){
var column = ‘第‘+(j+1)+‘列‘;
trs[i].children[j].result = row+column;
trs[i].children[j].onclick = function(){
$(‘#result‘).html(this.result);
}
}
}
}
</script>
</head>
<body>
<table border=‘1px solid gray‘>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
被点击的单元格位于:
<div id=‘result‘ class="">
</div>
</body>
</html>