Here i have created a responsive bootstrap table where i want to add rows dynamically for which i am using jquery. But table body rows are not aligning properly with their respective headers as shown below
$(document).ready(function() {
var rows = "";
var a = "test code";
$("#add_row").click(function() {
rows += "<tr><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td><td>" + a + "</td></tr>";
$(rows).appendTo("#myTable3 tbody");
});
});
#myTable3 th {
background-color: #009999;
color: white;
}
.table-fixed {}
#myTable3 tbody {
height: 100px;
overflow: auto;
}
#myTable3 thead,
.tbody {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="table-responsive">
<div class="row clearfix">
<table class="table table-striped table-bordered table-fixed table-hover table-condensed" style="border:0px; " id="myTable3">
<thead>
<tr>
<th width="">FileNo</th>
<th width="">Height</th>
<th width="">Weight</th>
<th width="">Temperature</th>
<th width="">Abdominal Circumference</th>
<th width="">Blood Pressure</th>
<th width="">Pulse</th>
<th width="">BMI</th>
<th width="">Chest Circumference</th>
<th width="">Time Recorded</th>
</tr>
</thead>
<tbody class="tbody">
</tbody>
</table>
<a id="add_row" class="btn btn-default pull-left">Add Row</a>
</div>
</div>
Above is the snippet which explains the above problem. But i have used display block for thead and tbody to obtain scroll for tbody. If i remove display block section in css, alignment of tbody and thead works properly, but i need scroll for tbody.
Please Help me Thanks