title: Can't dynamically add rows to a <TABLE> in IE?
body: <p>I have an AJAX application that downloads a JSON object and uses the data to add rows to an HTML &lt;table&gt; using Javascript DOM functions. It works perfectly... except in Internet Explorer. IE doesn't give any sort of error, and I've verified as best as I can that the code is being executed by the browser, but it simply has no effect. I created this quick and dirty page to demonstrate the problem:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;
  
  &lt;table id="employeetable"&gt;
      &lt;tr&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Job&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;script type="text/javascript"&gt;
      function addEmployee(employeeName, employeeJob) {
          var tableElement = document.getElementById("employeetable");
          if (tableElement) {
              var newRow = document.createElement("tr");
              var nameCell = document.createElement("td");
              var jobCell = document.createElement("td");
              nameCell.appendChild(document.createTextNode(employeeName));
              jobCell.appendChild(document.createTextNode(employeeJob));
              newRow.appendChild(nameCell);
              newRow.appendChild(jobCell);
              tableElement.appendChild(newRow);
              alert("code executed!");
          }
      }
  
      setTimeout("addEmployee(\"Bob Smith\", \"CEO\");", 1000);
      setTimeout("addEmployee(\"John Franks\", \"Vice President\");", 2000);
      setTimeout("addEmployee(\"Jane Doe\", \"Director of Marketing\");", 3000);
  &lt;/script&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I haven't tried IE 8, but both IE 7 and IE 6 do not show the additional rows that are supposedly being added. I can't fathom why. Does anyone know a good workaround to this problem, or am I perhaps doing something wrong?</p>