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.9.1.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-active", |
24 |
drop: function( event, ui ) { |
25 |
$( this ) |
26 |
.addClass( "ui-state-highlight" ) |
27 |
.find( "p" ) |
28 |
.html( "Dropped!" ); |
29 |
} |
30 |
}); |
31 |
|
32 |
$( "#draggable2" ).draggable(); |
33 |
$( "#droppable2" ).droppable({ |
34 |
accept: "#draggable2", |
35 |
activeClass: "ui-state-hover", |
36 |
drop: function( event, ui ) { |
37 |
$( this ) |
38 |
.addClass( "ui-state-highlight" ) |
39 |
.find( "p" ) |
40 |
.html( "Dropped!" ); |
41 |
} |
42 |
}); |
43 |
}); |
44 |
</script> |
45 |
</head> |
46 |
<body> |
47 |
|
48 |
<h3>Feedback on hover:</h3> |
49 |
|
50 |
<div id="draggable" class="ui-widget-content"> |
51 |
<p>Drag me to my target</p> |
52 |
</div> |
53 |
|
54 |
<div id="droppable" class="ui-widget-header"> |
55 |
<p>Drop here</p> |
56 |
</div> |
57 |
|
58 |
<h3>Feedback on activating draggable:</h3> |
59 |
|
60 |
<div id="draggable2" class="ui-widget-content"> |
61 |
<p>Drag me to my target</p> |
62 |
</div> |
63 |
|
64 |
<div id="droppable2" class="ui-widget-header"> |
65 |
<p>Drop here</p> |
66 |
</div> |
67 |
|
68 |
<div class="demo-description"> |
69 |
<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> |
70 |
</div> |
71 |
</body> |
72 |
</html> |