0
我有以下代碼,可以將div拖入3個框中。
我試圖讓可拖動的div適合從你放在它上面的盒子中的盒子,因爲此刻它會掉落它,但它允許它在窗口上的任何位置掉落,我怎麼能阻止這種情況發生?如何將div拖入框
<div id="drop1" class="dropzone">Accepts the element if fits inside</div>
<div id="drop2" class="dropzone">Accepts the element if intersects</div>
<div id="drop3" class="dropzone">Accepts the element if pointer hovers</div>
<div id="drag" class="dropaccept">Drag me</div>
<script type="text/javascript">
$(document).ready(
function()
{
$('#drag').Draggable();
$('#drop1').Droppable(
{
accept : 'dropaccept',
activeclass: 'dropactive',
hoverclass: 'drophover',
tolerance: 'intersect'
}
);
$('#drop2').Droppable(
{
accept : 'dropaccept',
activeclass: 'dropactive',
hoverclass: 'drophover',
tolerance: 'intersect'
}
);
$('#drop3').Droppable(
{
accept : 'dropaccept',
activeclass: 'dropactive',
hoverclass: 'drophover',
tolerance: 'intersect'
}
);
}
);
</script>
我剛剛試過,它停止工作的整個代碼 – Rickstar 2010-10-06 16:32:51
@Gully - 你不使用jQuery UI嗎?它看起來非常相似,但你的代碼框全部關閉......你在使用一個試圖模擬[jQuery UI Drag&Drop](http://jqueryui.com/demos/droppable/)的庫嗎? – 2010-10-06 16:33:58