<script>
var e = document.getElementById("tab");
for(var i=0; e.rows && i<e.rows.length; i++){
  for(var j=0; e.rows(i).cells && j<e.rows(i).cells.length; j++){
       e.rows(i).cells.attachEvent("onclick",functionName);  
       /*
        e.rows(i).cells.attachEvent("onclick",function(){
             alert(this);
       });      
       */
  }
}
function functionName(e){alert(e);}
</script><table id=tab></table>
没试~