好的,我想要创建的是:可拖动的元素,适合表格单元格(.slot divs)。以下是使用jQuery UI的代码的简化版本:
<style>
.draggable, .cell {
width: 100px; height: 100px;
}
.cell {
background: #F00;
}
</style>
<script type="text/javascript">
$(function() {
$( ".draggable" ).draggable({
distance: 20,
containment: "#container",
snap: ".slot",
snapMode: "inner",
snapTolerance: 10,
});
});
</script>
<table id=”container”>
<tr>
<td class=”cell”> <div class=”slot”> <div class=”draggable”></div> </div> </td>
<td class=”cell”> <div class=”slot”></div> </td>
</tr>
<tr>
<td class=”cell”> <div class=”slot”> <div class=”draggable”></div> </div> </td>
<td class=”cell”> <div class=”slot”></div> </td>
</tr>
<tr>
<td class=”cell”> <div class=”slot”></div> </td>
<td class=”cell”> <div class=”slot”></div> </td>
</tr>
</table>
从现在开始我可以在细胞周围移动它们(.slot),但我无法实现两件事:
感谢任何建议或帮助!
提前致谢,乔治