【发布时间】:2011-10-13 15:42:33
【问题描述】:
以下代码来自演示http://www.jqueryui.com/demos/droppable/
#draggable 掉到#droppable 之后,我不能把它移到#draggable 外面,所以它总是粘在#draggable 里面,只有我可以把它移到#droppable 里面吗?
<style>
#draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
#droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
</style>
<script>
$(function() {
$( "#draggable" ).draggable();
$( "#" ).droppable({
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" );
}
});
});
</script>
<div class="demo">
<div id="draggable" class="ui-widget-content">
<p>Drag me to my target</p>
</div>
<div id="droppable" class="ui-widget-header">
<p>Drop here</p>
</div>
</div><!-- End demo -->
<div style="display: none;" class="demo-description">
<p>Enable any DOM element to be droppable, a target for draggable elements.</p>
</div><!-- End demo-description -->
感谢您的帮助
编辑: 抱歉,我找到了解决方案:http://jqueryui.com/demos/droppable/#revert
【问题讨论】:
-
如果您有解决方案,请将其放在答案中并接受