我有一些表,例如:
<table class="table table-hover table-striped" id="mytable">
<thead>
<tr>
<th>#</th>
<th>Table heading 1</th>
<th>Table heading 2</th>
<th>Table heading 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
</tbody>
</table>
然后我想制作可排序表的行标题。
$('#mytable thead tr').sortable({
axis: "x",
helper: "clone"
}).disableSelection();
问题:
当我开始拖放时,我有 6 个th
-s 而不是 4 个:
<tr class="ui-sortable">
<th>#</th>
<th style="
display: none;">Table heading 1</th>
<th class="ui-sortable-placeholder"
style="
visibility: hidden;"></th>
<th>Table heading 2</th>
<th>Table heading 3</th>
<th style="
display: table-cell;
width: 343px;
height: 37px;
position: absolute;
z-index: 1000;
left: 184px;"
class="ui-sortable-helper">Table heading 1</th>
</tr>
..所有标记开始变得非常不稳定和不确定:当我将th
项目拖到表格上时,我看到所有行的大小都在跳跃。
很明显,这是因为计数th
项目(不等于 中的td
项目数tr
)而发生的。
如何修复这个?