id 属性可设置或返回表元的 id。
tabledataObject.id=id
下面的例子返回的表元的 id:
<html>
<head>
<script type="text/javascript">
function alertId()
{
alert(document.getElementById("td1").id
);
}
</script>
</head>
<body>
<table border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td id="td1">Peter</td>
<td id="td2">Griffin</td>
</tr>
</table>
<br />
<input type="button" onclick=alertId() value="Alert ID" />
</body>
</html>