This is my code to add rows to a table
for(var i=0;i<subjects.length;i++){
$('#table-wrapper table').append("<tr><td data-subjectid="+i+">"+subjects[i].name+"</td>");
for(var j=0;j<no_of_batches;j++){
$('#table-wrapper table').append("<td data-batchid="+j+"></td>");
}
$('#table-wrapper table').append("</tr>");
}
The output this produces is
<table>
<tbody>
<tr>
<tr>
<td data-subjectid="2">DBMS</td>
</tr>
</tbody>
<td data-batchid="0"></td>
<td data-batchid="1"></td>
<td data-batchid="2"></td>
<td data-batchid="3"></td>
</table>
Why aren't the inner <td>'s getting appended to the <tr> tag at the end of the table but instead out of the <tbody>
for.