2011-10-13 59 views
1

這下面的代碼是從演示http://www.jqueryui.com/demos/droppable/jQuery的,下降的div棒可拖動區域

是否有可能後#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

+1

如果您有解決方案,請將其置於答案中並接受 – jammypeach

回答