<html>
<head>
<script language="javascript">
function td_Capture(td_value)
{
  var td_value;
  td_value = document.getElementById("td1");
  alert(td_value.innerHTML);
}
</script>
</head>
<body>
<table border="1">
<tr>
  <td id="td1" onclick="td_Capture()">this is td's value</td>
</tr>
</table>
</body>
</html>

解决方案 »

  1.   

    题目理解错了,这样改一下就可以获取每个表格列的主属性了:<html>
    <head>
    <script language="javascript">
    function td_Capture(td_value)
    {
      var td_value;
      td_value = document.getElementById(td_value);
      alert(td_value.innerHTML);
    }
    </script>
    </head>
    <body>
    <table border="1">
    <tr>
      <td id='td1' onclick="td_Capture('td1')" bgcolor="#cccccc">this is Father's value</td>
    </tr>
    <tr>
      <td id='td2' onclick="td_Capture('td1')">this is td's value</td>
    </tr>
    <tr>
      <td id='td3' onclick="td_Capture('td1')">this is td's value</td>
    </tr>
    </table>
    </body>
    </html>
      

  2.   

    表中的内容都是根据数据库读出来的,所以行数,列数都会变测试代码是这样的
    <!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 src="select.js" type="text/javascript" language="javascript"></script>
    </head><body>
    <form method="post" action="save.jsp">
    <table cellspacing="0" cellpadding="1" border="1"> 
    <tr> 
         <td>depth </td> <td>A </td> <td>B </td> 
    </tr> 
    <tr> 
         <td>200 </td> <td onclick="getvalue(this)">-2 </td> <td onclick="getvalue(this)">2 </td> 
    </tr> 
    <tr> 
         <td>300 </td> <td onclick="getvalue(this)">-3 </td> <td onclick="getvalue(this)">3 </td> 
    </tr> 
    <tr> 
         <td>400 </td> <td onclick="getvalue(this)">-4 </td> <td onclick="getvalue(this)">4 </td> 
    </tr>      </table> 当前值:<input type="text" id=mytext name="mytext" /> <br/>
    对应属性是:<input type="text" id="t" name="t"/><br/>
    深度:<input type="text" id="depth" name="depth"/><br/><script> 
    function getvalue(o){ 
       document.getElementById("mytext").value = o.innerHTML 
       //alert(parentNode.firstChild.innerHTML);//取的后可以做其他用. 
       //var deep=parentNode.firstChild.innerHTML ;
       document.getElementById("depth").value=o.parentNode.cells[0].innerHTML;

    </script><input type="submit" value="submit"/>
    </form>
    </body>
    </html>我只完成了一部分
      

  3.   

    上面的js改成这样就可以了。
    function getvalue(o){ 
       document.getElementById("mytext").value = o.innerHTML 
       //alert(parentNode.firstChild.innerHTML);//取的后可以做其他用. 
       //var deep=parentNode.firstChild.innerHTML ;
       document.getElementById("depth").value=o.parentNode.cells[0].innerHTML;
       document.getElementById("t").value=o.parentElement.parentElement.rows[0].cells[event.srcElement.cellIndex].innerHTML;
       //document.getElementById("t").value=o.rows[0].innerHTML;} 
    </script>[