gpt4 book ai didi

jquery - jquery 中两个相似表之间的表行拖放,可拖放

转载 作者:行者123 更新时间:2023-12-01 00:40:32 25 4
gpt4 key购买 nike

我正在尝试拖动表格行并将其放入类似的表格中,即具有相同的表格结构。

我正在尝试使用 j query Drag-gable 来实现,但无法修复它。

我发现很少jsfiddle链接

$("tbody.connectedSortable")
.sortable({
connectWith: ".connectedSortable",
items: "> tr:not(:first)",
appendTo: $tabs,
helper: "clone",
zIndex: 999990,
start: function () {
$tabs.addClass("dragging")
},
stop: function () {
$tabs.removeClass("dragging")
}
})

但这里我没有其他表的选项卡。

最佳答案

JS FIDDLE

Jquery

var $tabs = $('#table-draggable2')
$("tbody.connectedSortable")
.sortable({
connectWith: ".connectedSortable",
items: "> tr:not(:first)",
appendTo: $tabs,
helper: "clone",
zIndex: 999990
})
.disableSelection();
var $tab_items = $(".nav-tabs > li", $tabs).droppable({
accept: ".connectedSortable tr",
hoverClass: "ui-state-hover",
drop: function (event, ui) {
return false;
}
});

HTML

<table id='table-draggable1'>
<tbody class="connectedSortable">
<tr>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
</tr>
<tr>
<td>156</td>
<td>668</td>
<td>100.95</td>
<td>1.82</td>
</tr>
<tr>
<td>256</td>
<td>668</td>
<td>100.95</td>
<td>1.82</td>
</tr>
</tbody>
</table>
<table id='table-draggable2'>
<tbody class="connectedSortable">
<tr>
<th>COL1</th>
<th>COL2</th>
<th>COL3</th>
<th>COL4</th>
</tr>
<tr>
<td>356</td>
<td>668</td>
<td>100.95</td>
<td>1.82</td>
</tr>
<tr>
<td>456</td>
<td>668</td>
<td>100.95</td>
<td>1.82</td>
</tr>
</tbody>
</table>

关于jquery - jquery 中两个相似表之间的表行拖放,可拖放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22437946/

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