visual-feedback.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI Droppable - Visual feedback</title>
  6. <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
  7. <script src="../../jquery-1.10.2.js"></script>
  8. <script src="../../ui/jquery.ui.core.js"></script>
  9. <script src="../../ui/jquery.ui.widget.js"></script>
  10. <script src="../../ui/jquery.ui.mouse.js"></script>
  11. <script src="../../ui/jquery.ui.draggable.js"></script>
  12. <script src="../../ui/jquery.ui.droppable.js"></script>
  13. <link rel="stylesheet" href="../demos.css">
  14. <style>
  15. #draggable, #draggable2 { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
  16. #droppable, #droppable2 { width: 120px; height: 120px; padding: 0.5em; float: left; margin: 10px; }
  17. h3 { clear: left; }
  18. </style>
  19. <script>
  20. $(function() {
  21. $( "#draggable" ).draggable();
  22. $( "#droppable" ).droppable({
  23. hoverClass: "ui-state-hover",
  24. drop: function( event, ui ) {
  25. $( this )
  26. .addClass( "ui-state-highlight" )
  27. .find( "p" )
  28. .html( "Dropped!" );
  29. }
  30. });
  31. $( "#draggable2" ).draggable();
  32. $( "#droppable2" ).droppable({
  33. accept: "#draggable2",
  34. activeClass: "ui-state-default",
  35. drop: function( event, ui ) {
  36. $( this )
  37. .addClass( "ui-state-highlight" )
  38. .find( "p" )
  39. .html( "Dropped!" );
  40. }
  41. });
  42. });
  43. </script>
  44. </head>
  45. <body>
  46. <h3>Feedback on hover:</h3>
  47. <div id="draggable" class="ui-widget-content">
  48. <p>Drag me to my target</p>
  49. </div>
  50. <div id="droppable" class="ui-widget-header">
  51. <p>Drop here</p>
  52. </div>
  53. <h3>Feedback on activating draggable:</h3>
  54. <div id="draggable2" class="ui-widget-content">
  55. <p>Drag me to my target</p>
  56. </div>
  57. <div id="droppable2" class="ui-widget-header">
  58. <p>Drop here</p>
  59. </div>
  60. <div class="demo-description">
  61. <p>Change the droppable's appearance on hover, or when the droppable is active (an acceptable draggable is dropped on it). Use the <code>hoverClass</code> or <code>activeClass</code> options to specify respective classes.</p>
  62. </div>
  63. </body>
  64. </html>