为什么我不能在Internet Explorer中使用JavaScript动态地将行添加到HTML表中?

use*_*021 1 javascript internet-explorer

在Firefox中它可以工作,在我的Internet Explorer 6或7中它没有:

<html>
<head>

    <script type="text/javascript">
      function newLine() {
        var tdmod = document.createElement('td');
        tdmod.appendChild(document.createTextNode("dynamic"));

        var tr = document.createElement('tr');
        tr.appendChild(tdmod);

        var tt  = document.getElementById("t1");
        tt.appendChild(tr);
      }     

    </script>
</head>
<body>

    <a href="#" onclick="newLine()">newLine</a>

      <table id="t1" border="1">
        <tr>
          <td>
          static
          </td>  
        </tr>
      </table>

</body>
Run Code Online (Sandbox Code Playgroud)

用户单击链接"newLine",新行应添加到表中.

如何在IE中使这项工作?

编辑:感谢接受的答案,我改变了它,现在它的工作原理:

  <table border="1">
   <tbody id="t1">
    <tr>
      <td>
      static
      </td>  
    </tr>
   </tbody>
  </table>
Run Code Online (Sandbox Code Playgroud)

cob*_*bal 7

(未经测试)您可以尝试将行附加到tbody元素,通常是自动创建的元素或您自己定义的元素.