sort.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Change Items Order - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Change Items Order</h2>
  14. <p>Drag the list items to change their order.</p>
  15. <div style="margin:20px 0;"></div>
  16. <ul style="margin:0;padding:0;margin-left:10px;">
  17. <li class="drag-item">Drag 1</li>
  18. <li class="drag-item">Drag 2</li>
  19. <li class="drag-item">Drag 3</li>
  20. <li class="drag-item">Drag 4</li>
  21. <li class="drag-item">Drag 5</li>
  22. <li class="drag-item">Drag 6</li>
  23. </ul>
  24. <style type="text/css">
  25. .drag-item{
  26. list-style-type:none;
  27. display:block;
  28. padding:5px;
  29. border:1px solid #ccc;
  30. margin:2px;
  31. width:300px;
  32. background:#fafafa;
  33. color:#444;
  34. }
  35. .indicator{
  36. position:absolute;
  37. font-size:9px;
  38. width:10px;
  39. height:10px;
  40. display:none;
  41. color:red;
  42. }
  43. </style>
  44. <script>
  45. $(function(){
  46. var indicator = $('<div class="indicator">>></div>').appendTo('body');
  47. $('.drag-item').draggable({
  48. revert:true,
  49. deltaX:0,
  50. deltaY:0
  51. }).droppable({
  52. onDragOver:function(e,source){
  53. indicator.css({
  54. display:'block',
  55. left:$(this).offset().left-10,
  56. top:$(this).offset().top+$(this).outerHeight()-5
  57. });
  58. },
  59. onDragLeave:function(e,source){
  60. indicator.hide();
  61. },
  62. onDrop:function(e,source){
  63. $(source).insertAfter(this);
  64. indicator.hide();
  65. }
  66. });
  67. });
  68. </script>
  69. </body>
  70. </html>