in the html i have an empty table tag.
<table cellpadding="5" cellspacing="5" border="0" id="TableID" class='TableOne'>
</table>
<input id="btn" value="test" type="button" />
in a jscript function, i'm adding some initial rows to the table, one of which contains another table.
$('#btn').click(function() {
var html = '';
html += "\
<tr>\
<td>Row1\
<table>\
<tr>\
<td></td>\
</tr>\
</table>\
</td>\
</tr>\
<tr>\
<td>Row2</td>\
</tr>";
$('#TableID').html(html);
var newhtml = "<tr><td>Row3</td></tr>";
$('#TableID').append(newhtml);
});
...
.tableOne
{
border: 3px solid black;
}
.tableTwo
{
border: 2px solid red;
}
When this code is executed.... instead of seeing
Row1 Row2 Row3
we see
Row1 Row3 Row2
Row 3 is being put within the inner table. Not the table I specified by id.... how can i fix this??
Edit:
I'm not sure what the cause of this actually is, but I found a work around.
<table cellpadding="5" cellspacing="5" border="0" class='tableOne'>
<tbody id="TableID"></tbody>
</table>
<input id="btn" value="test" type="button" />
...
$('#btn').click(function() {
var html = '';
html += "\
<tr>\
<td>Row1\
<table>\
<tr>\
<td></td>\
</tr>\
</table>\
</td>\
</tr>\
<tr>\
<td>Row2</td>\
</tr>";
$('#TableID').html(html);
var newhtml = "<tr><td>Row3</td></tr>";
$('#TableID').append(newhtml);
});
..