如何解决如何从列表拖放到特定的表格单元格
如何从选项列表中进行拖放操作 我可以将列表中的特定选项拖放到表格单元格中,在这种情况下,可以拖放到客户地址的任何单元格中,(可以带有或表)并使用我从列表中拖动的选项更改单元格值。
我一直在尝试使用 sortableJS 来做到这一点,但我只能将该选项作为一行而不是在特定单元格中。
我想做的例子:
这是代码:
CSS:
<style>
.div-table {
display: table;
width: auto;
background-color: #eee;
border: 1px solid #666666;
border-spacing: 5px; /* cellspacing:poor IE support for this */
}
.div-table-row {
display: table-row;
width: auto;
clear: both;
}
.div-table-col {
float: left; /* fix for buggy browsers */
display: table-column;
width: 200px;
background-color: #ccc;
}
</style>
HTML:
<form id="form1">
<div class="div-table" id="table-left">
<div class="div-table-row">
<div class="div-table-col" align="center">Customer ID</div>
<div class="div-table-col">Customer Address</div>
</div>
<div class="div-table-row">
<div class="div-table-col">001</div>
<div class="div-table-col">003</div>
</div>
<div class="div-table-row">
<div class="div-table-col">ttt</div>
<div class="div-table-col">Mkkk</div>
</div>
</div>
</form>
<div class="table-list" id="list">
<p style="background: red; width: 200px">List</p>
<div>Option 1</div>
<div>Option 2</div>
</div>
JS :
<script src="http://SortableJS.github.io/Sortable/Sortable.js"></script>
<script>
const tablea = document.getElementById("table-left");
const list = document.getElementById("list");
new Sortable(tablea,{
group: "shared",// set both lists to same group
animation: 150,});
new Sortable(list,animation: 150,});
</script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。