forked from scruffian/javascripture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dragdrop.html
43 lines (40 loc) · 1.17 KB
/
dragdrop.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Draggable - Default functionality</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<style>
.draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>
<script>
$(function() {
$( ".draggable" ).draggable();
$( "#droppable" ).droppable({
drop: function( event, ui ) {
var count = $(this).data('count') + 1;
console.log(count);
$( this )
.addClass( "ui-state-highlight" )
.find( "p" )
.html( "Dropped!" + count )
.data('count', count);
}
});
});
</script>
</head>
<body>
<div id="" class="draggable ui-widget-content">
<p>Drag me around</p>
</div>
<div id="draggable" class="draggable ui-widget-content">
<p>Drag me around</p>
</div>
<div id="droppable" class="ui-widget-header" data-count="0">
<p>Drop here</p>
</div>
</body>
</html>