jQuery UI Interaction : Droppable
This page discusses - jQuery UI Interaction : Droppable
This page discusses - jQuery UI Interaction : Droppable
jQuery UI Interaction : Droppable

jQuery UI Interaction : Droppable
Using jQuery droppable plug-in , you can make selected elements
droppable (meaning they accept being dropped on by draggables).
All callbacks receive two arguments: The original browser event and a
prepared ui object, view below for a documentation of this object (if you name
your second argument 'ui'):
- ui.draggable - current draggable element, a jQuery object.
- ui.helper - current draggable helper, a jQuery object
- ui.position - current position of the draggable helper { top: ,
left: }
- ui.offset - current absolute position of the draggable helper {
top: , left: }
For options, events and method click here
Example :
droppable.html
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui
/1.8/themes/base/jquery-ui.css"
rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js">
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">
</script>
<style type="text/css">
#draggable { width: 75px; height: 25px; background: silver; padding: 10px; }
#droppable { position: absolute; left: 250px; top: 0; width: 125px; height:
75px;
background: gray; color: white; padding: 10px; }
</style>
<script>
$(document).ready(function() {
$("#draggable").draggable();
$("#droppable").droppable({
drop: function() { alert('dropped'); }
});
});
</script>
</head>
<body style="font-size:62.5%;">
<div id="droppable">Drop here</div>
<div id="draggable">Drag me</div>
</body>
</html> |
Output :
When you drop small box on big one , it will show a alert message :

Learn from experts! Attend
jQuery Training classes.
Ads