如何得到table里面的ID
<html>
<head>
<title>Table Test</title>
<meta name="generator" content="Editplus" />
<meta name="author" content="PJ" />
<script language="JavaScript">
<!--
function Delete()
{
var dgTable=document.getElementById('tb').rows;//tb为table的ID,
var pp=window.event.srcElement;
for (var i=0; i < dgTable.length; i++) //遍历table的行,
{
if(pp==dgTable[i].cells[2].getElementsByTagName("A")[0]) //cells[2]为触发事件的列的索引
{ //判断是否是触发事件的A标签
alert(dgTable[i].cells[0].innerText); //演示,弹出所在行的第一列的内容
}
}
}
//-->
</script>
</head>
<body>
<table id="tb" border="1px" width="500px">
<tbody>
<tr>
<td width="40%">aaa</td>
<td width="40%">bbb</td>
<td width="15%"><a onClick="Delete()" href="#">delete</a></td>
</tr>
<tr>
<td>ccc</td>
<td>ddd</td>
<td><a onClick="Delete()" href="#">delete</a></td>
</tr>
<tr>
<td>eee</td>
<td>fff</td>
<td><a onClick="Delete()" href="#">delete</a></td>
</tr>
</tbody>
</table>
</body>
</html>