tr.onclick=function() {select(this)}

解决方案 »

  1.   

    tr.onclick=select(this)
    调用的select 函数吧.
      

  2.   

    var tr=tblList.insertRow(tblList.rows.length);
    tr.setAttribute('style', 'cursor:hand');
    tr.setAttribute('align', 'center');...
      

  3.   

    tr.onclick=function() {select(this)}没问题
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script>
     function g(v){
      alert(v.cells.length);
     }
     function f(){
       var newline=document.all.myt.insertRow(document.all.myt.rows.length);
       newline.onclick=function () {g(this);}
       cell0=newline.insertCell(0);   cell0.innerHTML="aa";
       cell0=newline.insertCell(1);   cell0.innerHTML="bb";
       cell0=newline.insertCell(2);   cell0.innerHTML="bb";
     }
    </script>
    </head><body>
    <table width="200" border="1" id="myt">
      <tr onClick="g()">
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <input type="button" name="Submit" value="按钮" onClick="f()">
    </body>
    </html>
      

  5.   

    再完善一点,如下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script>
     function select(v){
      alert(v.cells.length);
     }
     function f(){
       var newline=document.all.myt.insertRow(document.all.myt.rows.length);
       newline.onclick=function () {select(this);}
       newline.style.cursor='hand';
       newline.align='center';
       cell0=newline.insertCell(0);   cell0.innerHTML="aa";
       cell0=newline.insertCell(1);   cell0.innerHTML="bb";
       cell0=newline.insertCell(2);   cell0.innerHTML="bb";
     }
    </script>
    </head><body>
    <table width="200" border="1" id="myt">
      <tr onClick="g()">
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    <input type="button" name="Submit" value="按钮" onClick="f()">
    </body>
    </html>
      

  6.   

    <script language=javascript>
    function select()
    {
    alert('selected!');
    }function add()
    {
    var tr=document.getElementById('t1').insertRow();
    tr.style.cursor="hand";
    tr.onclick=function() {select(this)}
    tr.insertCell().appendChild(document.createTextNode('xxx'))
    }
    </script><table border=1 id="t1">
    <tr style="cursor:hand" onclick="select(this)"><td>111</td></tr>
    </table><input type=button value="新增" onclick="add()">至于align,只能放在cell中
      

  7.   

    别的属性好像倒是能的,以前整过,但是不知道在insertRow()以后,能不能设置class(css),以前试过,一直没有找到方法啊!
      

  8.   

    setAtrigute(childNodesname,vValue)即可达到