我有如下表格。问题我有一个如下运行的ajax脚本
$.post('getDt.php', {a: ""}, function(data){
$('#updateData').html(data);
}
将表体内容动态填充到div #updateData。不幸的是,div 总是出现在表格内容的顶部。它永远不会按照定义填充到正文部分。如何强制它出现在正文而不是表格顶部?
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable " style='font-size:10px;table-layout: fixed;'>
<thead>
<tr>
<th style='width: 10%;'>No.</th>
<th style='width: 15%;'>NT</th>
<th style='width: 20%;'>SE</th>
<th style='width: 20%;'>VH</th>
<th style='width: 18%;'>Status</th>
</tr>
</thead>
<tbody>
<div id="updateData">
</div>
</tbody>
</div>
最佳答案
<tbody>
元素只能包含 <tr>
元素。
我建议您创建一个行 (tr) 和一个单元格 (td) 并放置您的 <div>
内的元素。
也就是说,除非从 AJAX 调用返回的数据是实际行,否则我会将 id 属性移至 <tbody>
元素并删除 <div>
元素。
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable " style='font-size:10px;table-layout: fixed;'>
<thead>
<tr>
<th style='width: 10%;'>No.</th>
<th style='width: 15%;'>NT</th>
<th style='width: 20%;'>SE</th>
<th style='width: 20%;'>VH</th>
<th style='width: 18%;'>Status</th>
</tr>
</thead>
<tbody id="updateData">
</tbody>
</div>
关于jquery - 将 tbody 更新为 div 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27360354/