[683] | 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.6.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 | </style> |
---|
| 18 | <script> |
---|
| 19 | $(function() { |
---|
| 20 | $( "#draggable" ).draggable(); |
---|
| 21 | $( "#droppable" ).droppable({ |
---|
| 22 | hoverClass: "ui-state-active", |
---|
| 23 | drop: function( event, ui ) { |
---|
| 24 | $( this ) |
---|
| 25 | .addClass( "ui-state-highlight" ) |
---|
| 26 | .find( "p" ) |
---|
| 27 | .html( "Dropped!" ); |
---|
| 28 | } |
---|
| 29 | }); |
---|
| 30 | |
---|
| 31 | $( "#draggable2" ).draggable(); |
---|
| 32 | $( "#droppable2" ).droppable({ |
---|
| 33 | accept: "#draggable2", |
---|
| 34 | activeClass: "ui-state-hover", |
---|
| 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 | |
---|
| 47 | <div class="demo"> |
---|
| 48 | |
---|
| 49 | <h3 class="docs">Feedback on hover:</h3> |
---|
| 50 | |
---|
| 51 | <div id="draggable" class="ui-widget-content"> |
---|
| 52 | <p>Drag me to my target</p> |
---|
| 53 | </div> |
---|
| 54 | |
---|
| 55 | <div id="droppable" class="ui-widget-header"> |
---|
| 56 | <p>Drop here</p> |
---|
| 57 | </div> |
---|
| 58 | |
---|
| 59 | <h3 class="docs">Feedback on activating draggable:</h3> |
---|
| 60 | |
---|
| 61 | <div id="draggable2" class="ui-widget-content"> |
---|
| 62 | <p>Drag me to my target</p> |
---|
| 63 | </div> |
---|
| 64 | |
---|
| 65 | <div id="droppable2" class="ui-widget-header"> |
---|
| 66 | <p>Drop here</p> |
---|
| 67 | </div> |
---|
| 68 | |
---|
| 69 | </div><!-- End demo --> |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | <div class="demo-description"> |
---|
| 74 | <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> |
---|
| 75 | </div><!-- End demo-description --> |
---|
| 76 | |
---|
| 77 | </body> |
---|
| 78 | </html> |
---|