<table>
 
 <tbody>
 
   <tr id="test"><td></td></tr>
 
 </tbody>
 
 </table>
 
  
 
 document.getElementById("test").setAttribute("onclick","Test()");
 
 var Test=function(){
 
   alert(Object.prototype.toString.call(this));
 
 };
 
 结果显示: [object Window]
 
  
 
 要想取得tr,正确的做法是:
 
 document.getElementById("test").setAttribute("onclick","Test(this)");
 
 var Test=function(row){
 
   alert(row.cells.length);
 
 };
 
 结果显示:1
 
 正确了,呵呵.
 
转载于:https://www.cnblogs.com/hongjiumu/archive/2012/09/08/2676315.html