<table id=hrong border=1 width=300>
<tr><td>黄1</td><td>蓉1</td></tr>
<tr><td>黄2</td><td>蓉2</td></tr>
<tr><td>黄3</td><td>蓉3</td></tr>
</table>
<SCRIPT LANGUAGE="JavaScript">
function searchObjByTagName(obj, tag)
{
  while(obj!=null && typeof(obj.tagName) != "undefind")
  {
    if(obj.tagName == tag.toUpperCase()) return(obj);
    obj = obj.parentElement;
  }
  return null;
}
document.all.hrong.attachEvent("onclick", function(){
var e = window.event.srcElement;
var td = searchObjByTagName(e, "td");
alert(td.innerText);
});
</SCRIPT>

解决方案 »

  1.   

    使用 document.activeElement 可以得到鼠标点中的元素的属性
      

  2.   

    首先谢谢黄蓉的回答!看了你的回复,的确实现了我所问的功能,但却不是我想要得,都怪我没问清楚 :)我要实现的功能是:
    (1).用鼠标双击table A某一行,然后把这行中的所有单元格的值付给另一个table B;(我现在的问题是当鼠标选中这行时不知如何表示这行的每一个单元格的值)(2).然后在table B中修改这些值,之后按一个按钮可把这些值再存回table A中的原行。下面是我的代码:
    <html><head></head><body>
     <script>
    function a(o)
    {
    o.bgColor="#FF00FF"
    }function b(o)
    {
    o.bgColor="#3399FF"
    }
    function tiqu(o)
    {
    这里边要实现提取这行的值并付给tableB}
     </script>   <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableA">
              <tr onclick='tiqu(this)'  style='cursor:hand' onmouseover='a(this)' onmouseout='b(this)'>>
               
                <td width="20%">设备类型</td>
                <td width="36%">设备名称</td>
                <td width="20%">设备型号</td>
              </tr>
              </table>
              
              
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableB">
              <tr >
               
                <td width="20%"><input type="text" name="T1" size="20"></td>
                <td width="36%"><input type="text" name="T1" size="20"></td>
                <td width="20%">   <input type="button" value="保存" name="B3"></td>
                <td width="20%"> </td>
                <td width="36%">   </td>
                <td width="20%">   </td>
              </tr>
              
               <tr >
               
                <td width="20%"><input type="text" name="T1" size="20"></td>
                <td width="36%">   </td>
                <td width="20%">   </td>
                <td width="20%"> </td>
                <td width="36%">   </td>
                <td width="20%">   </td>
              </tr>
             
              </table>
    </body></html>
      

  3.   

    <html><head></head><body>
     <script>
    function a(o)
    {
    o.bgColor="#FF00FF"
    }function b(o)
    {
    o.bgColor="#3399FF"
    }
    function tiqu(o)
    {alert(o.cells[0].innerText);
    alert(o.cells[1].innerText);
    alert(o.cells[2].innerText);
    }
     </script>   <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableA">
              <tr onclick='tiqu(this)' >
               
                <td width="20%">设备类型</td>
                <td width="36%">设备名称</td>
                <td width="20%">设备型号</td>
              </tr>
              <tr onclick='tiqu(this)'  style='cursor:hand' onmouseover='a(this)' onmouseout='b(this)'>
                <td width="20%">类型1</td>
                <td width="36%">名称1</td>
                <td width="20%">型号1</td>
              </tr>
              </table>
              
              
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableB">
              <tr >
               
                <td width="20%"><input type="text" name="T1" size="20"></td>
                <td width="36%"><input type="text" name="T1" size="20"></td>
                <td width="20%">   <input type="button" value="保存" name="B3"></td>
                <td width="20%"> </td>
                <td width="36%">   </td>
                <td width="20%">   </td>
              </tr>
              
               <tr >
               
                <td width="20%"><input type="text" name="T1" size="20"></td>
                <td width="36%">   </td>
                <td width="20%">   </td>
                <td width="20%"> </td>
                <td width="36%">   </td>
                <td width="20%">   </td>
              </tr>
             
              </table>
    </body></html>
      

  4.   

    你要的是不是这样的??
    <html><head></head><body>
    <script>
    function a(o)
    {
    o.bgColor="#FF00FF"
    }function b(o)
    {
    o.bgColor="#3399FF"
    }
    function tiqu(o)
    {
    document.main.tu.value=o.rowIndex;
    document.main.T1.value=o.cells[0].innerText;
    document.main.T2.value=o.cells[1].innerText;
    document.main.T3.value=o.cells[2].innerText;}
    function mo()
    {
    document.all.tableA.rows[document.main.tu.value].cells[0].innerText=document.main.T1.value;
    document.all.tableA.rows[document.main.tu.value].cells[1].innerText=document.main.T2.value;
    document.all.tableA.rows[document.main.tu.value].cells[2].innerText=document.main.T3.value;
    }
     </script>
    <form name="main" >
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableA">
    <tr onclick='tiqu(this)' > 
    <td width="20%">设备类型</td>
    <td width="36%">设备名称</td>
    <td width="20%">设备型号</td>
    </tr>
    <tr onclick='tiqu(this)'  style='cursor:hand' onmouseover='a(this)' onmouseout='b(this)'> 
    <td width="20%">类型1</td>
    <td width="36%">名称1</td>
    <td width="20%">型号1</td>
    </tr>
    <tr onclick='tiqu(this)'  style='cursor:hand' onmouseover='a(this)' onmouseout='b(this)'> 
    <td width="20%">类型2</td>
    <td width="36%">名称2</td>
    <td width="20%">型号2</td>
    </tr>
    </table>
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableB">
    <tr > 
    <td width="20%"><input type="text" name="T1" size="20"></td>
    <td width="36%"><input name="T2" type="text" id="T2" size="20"></td>
    <td width="20%"> <input type="button" value="保存" name="B3" onClick="mo()"></td>
    <td width="20%"> </td>
    <td width="36%"> </td>
    <td width="20%"><input name="tu" type="text" id="tu"> </td>
    </tr>
    <tr > 
    <td width="20%"><input name="T3" type="text" id="T3" size="20"></td>
    <td width="36%"> </td>
    <td width="20%"> </td>
    <td width="20%"> </td>
    <td width="36%"> </td>
    <td width="20%"> </td>
    </tr>
    </table>
    </form>
    </body></html>
      

  5.   

    谢谢aocool(知秋一叶) ,你写的就正是我想要得,最然我在看到你的代码前我也用另一种方法实现了,但还是谢谢你了!也谢谢JK_10000(JK) 了,我就是参考你的实现的。现在还有个问题:如何控制新插入的行的属性?下面是我的代码:
    <body>
     <script>
    function a(o)
    {
    o.bgColor="#FF00FF"
    }function b(o)
    {
    o.bgColor="#3399FF"
    }
    function tiqu(o)
    {
    alert(o.cells[0].innerText);
    alert(o.cells[1].innerText);
    alert(o.cells[2].innerText);
    }function addrow()
    {
    *****这里插入的一行如何实现与原有行相同的功能,也就是如何控制新插入行的属性****objTable = document.all.item("tableA"); //table1是需要操作的表格名字
    newRow = objTable.insertRow(); //表示从1行前插入newCell = newRow.insertCell();   //插入单元格,可以重复使用插入多个
    newCell.innerText="dd";newCell = newRow.insertCell();   //插入单元格,可以重复使用插入多个newCell.innerText="d";
    newCell = newRow.insertCell();   //插入单元格,可以重复使用插入多个
    newCell.innerText ="FF";}
     </script>   <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="tableA">
              <tr onclick='tiqu(this)' >
               
                <td width="20%">设备类型</td>
                <td width="36%">设备名称</td>
                <td width="20%">设备型号</td>
              </tr>
              <tr onclick='tiqu(this)'  style='cursor:hand' onmouseover='a(this)' onmouseout='b(this)'>
                <td width="20%">类型1</td>
                <td width="36%">名称1</td>
                <td width="20%">型号1</td>
              </tr>
              </table>
               <p><input type="button" value="按钮" name="B3" onclick="addrow()"></p>
              </body></html>谢谢了!