function Button2_onclick() {
            //var root = document.getElementById("tbody");
            var root = document.createElement('tbody');
            document.getElementById("tb").appendChild(root);
            for (var i = 0; i < 9; i++) {
                var newRow = root.insertRow();
                var newCell = newRow.insertCell();
                newCell.innerHTML = "(" + i + ", " + 0 + ")";
                newCell = newRow.insertCell();
                newCell.innerHTML = "(" + i + ", " + 1 + ")";
            }
        }
tb是table的ID
    <table border="1" style="width: 100%; border:solid 1px red; " id="tb">
    <!-- <tbody id="tbody"></tbody> -->
    </table>

解决方案 »

  1.   

    <html>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
        </style>
        <body > 
       <table border="1" style="width: 100%; border:solid 1px red; " id="tb">
      <!-- <tbody id="tbody"></tbody> -->
      </table>
      <input type="button" onClick="Button2_onclick()" value="click me" />
    <script type="text/javascript">
      function Button2_onclick() {
                //var root = document.getElementById("tbody");
                var root = document.createElement('tbody');
                

                for (var i = 0; i < 9; i++) {
    var tr = document.createElement('tr');
                    var td = document.createElement('td');
    var td1 = document.createElement('td');
                    td.innerHTML = "(" + i + ", " + 0 + ")";
                    td1.innerHTML = "(" + i + ", " + 1 + ")";
    tr.appendChild(td);
    tr.appendChild(td1);
    root.appendChild(tr);
                }
    document.getElementById("tb").appendChild(root);
            }
    </script>
        
            
        </body>
    </html>  
      

  2.   

    function Button4_onclick() {
                var tb = document.getElementById("tb");
                var root = document.getElementsByTagName("tbody")[0];
                for (var i = 0; i < 9; i++) {
                    var newRow = root.insertRow(-1);
                    var newCell = newRow.insertCell(0);
                    newCell.innerHTML = "(" + i + ", " + 0 + ")";
                    newCell = newRow.insertCell(1);
                    newCell.innerHTML = "(" + i + ", " + 1 + ")";
                }
            }
      

  3.   

    使用jquery,你这个问题的原因是因为insertRow()和insertCell() 在火狐下面是必须要带参数的,所以你的这个在火狐下不支持。  $(function(){
                             $("input[name='add']").click(function(){
                 var str = "<tr><td>AAAAA<td/><td>BBB<td/><tr/>";
                 $('#tb').append(str);
                 });
                            });