B
bgold12
I'm adding a <tr> element dynamically to a web page. The relevant HTML
starts off like the following:
<table><tbody id="tbodyID">
<tr>...</tr>
<tr>...</tr>
</tbody></table>
After the page has loaded, I use the following javascript code to add
a new table row:
var newRow = document.createElement('tr');
newRow.innerHTML = '<td><p>...</p></td><td><p>...</p></td><td><p>...</
p></td>';
var tbodyElem = document.getElementById('tbodyID');
tbodyElem.appendChild(newRow);
This works, except for one very strange thing: the table data open and
close tags (the <td> and </td>) disappear in the final innerHTML of
the new <tr> element! When I print the innerHTML of the element, I see
something like the following:
<p>...</p><p>...</p><p>...</p>
So everything remains except for the open and close <td> tags. How can
the innerHTML I set for the new <tr> element be stripped of particular
tags like this?
bgold12
starts off like the following:
<table><tbody id="tbodyID">
<tr>...</tr>
<tr>...</tr>
</tbody></table>
After the page has loaded, I use the following javascript code to add
a new table row:
var newRow = document.createElement('tr');
newRow.innerHTML = '<td><p>...</p></td><td><p>...</p></td><td><p>...</
p></td>';
var tbodyElem = document.getElementById('tbodyID');
tbodyElem.appendChild(newRow);
This works, except for one very strange thing: the table data open and
close tags (the <td> and </td>) disappear in the final innerHTML of
the new <tr> element! When I print the innerHTML of the element, I see
something like the following:
<p>...</p><p>...</p><p>...</p>
So everything remains except for the open and close <td> tags. How can
the innerHTML I set for the new <tr> element be stripped of particular
tags like this?
bgold12