I have used the answer of the following stackoverflow question Javascript / jQuery: How to dynamically add rows to table body (using arrays) , in order to achieve dynamic adding of table row. I also use a bootstrap theme. The adding is done correctly but the <td> are unaligned with the <th>.
My html code is the following:
<div class="row" id="dynamic_table">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
</div>
<div class="panel-body center">
<table class="table">
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
</tr>
</thead>
<tbody id="table_body">
</tbody>
</table>
</div>
</div>
</div>
</div>
While the jQuery code is the following:
tbody = "<tr><td>" + value1 +"</td><td>" + value2 +"</td><td>" + value3 + "</td><td>" + value4 +"</td></tr>";
$('#table_body').html(tbody);
Since I'm quite new in bootstrap framework and jQuery what should I do in order for the values to be aligned with the relevant headers?
.appendin place of.htmlso yourtbodyis not overwritten when adding multiple rows.display: <something other than table or table-cell>then the whole table can become unaligned.value1,value2, etc?