gpt4 book ai didi

jquery - 将 tbody 更新为 div 内容

转载 作者:太空宇宙 更新时间:2023-11-04 12:34:53 26 4
gpt4 key购买 nike

我有如下表格。问题我有一个如下运行的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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com