<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无??文档</title>
<script language="JavaScript" type="text/javascript">
function init()
{
var table = document.getElementById("table1");
var trlen = table.rows.length;
var tdlen = table.rows[0].cells.length;
for (row=0; row < trlen; row++)
{
for (col=0; col < tdlen; col++)
{
(function (x,y){var ttt=table.rows[x].cells[y];ttt.attachEvent("onclick",function(){ selcol(ttt) })})(row,col)
}
}
}
function selcol(td)
{
alert(td.innerHTML);
//其他代?......
}
</script>
</head><body onload="init();">
<table id="table1" width="200" border="1">
<tr>
<td>a</td>
<td>aa</td>
</tr>
<tr>
<td>b</td>
<td>bb</td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无??文档</title>
<script language="JavaScript" type="text/javascript">
function init()
{
var table = document.getElementById("table1");
var trlen = table.rows.length;
var tdlen = table.rows[0].cells.length;
for (row=0; row < trlen; row++)
{
for (col=0; col < tdlen; col++)
{
(function (x,y){var ttt=table.rows[x].cells[y];ttt.attachEvent("onclick",function(){ selcol(ttt) })})(row,col)
}
}
}
function selcol(td)
{
alert(td.innerHTML);
//其他代?......
}
</script>
</head><body onload="init();">
<table id="table1" width="200" border="1">
<tr>
<td>a</td>
<td>aa</td>
</tr>
<tr>
<td>b</td>
<td>bb</td>
</tr>
</table>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货