日期:2014-05-16 浏览次数:20346 次
<html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Droppable - Default functionality</title> <link rel="stylesheet" href="base/jquery.ui.all.css"> <script src="jquery-1.6.2.js"></script> <script src="jquery.ui.core.js"></script> <script src="jquery.ui.widget.js"></script> <script src="jquery.ui.mouse.js"></script> <script src="jquery.ui.draggable.js"></script> <script src="jquery.ui.droppable.js"></script> <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 () { $(".ui-widget-content").draggable({ revert: true }); $("#droppable").droppable({ drop: function( event, ui ) { $(this).append(ui.draggable); ui.draggable('option', 'revert', false); } }); }); </script> </head> <body> <div id="draggable" class="ui-widget-content"> 444 </div> <div id="droppable" class="ui-widget-header"> 555 </div> </body> </html>