jQuery - Interaction Drop-able


The Drop-able function can be used with interactions in JqueryUI.This function can be enabled drop-able functionality on any DOM element.We can drop the drag-able element by clicking on it with mouse.


Here is the simple syntax to use drag-able −

$( "#droppable" ).droppable();


Following is a simple example showing the usage of drop-able −

Live Demo
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      <script type = "text/javascript" language = "javascript">
         $(function() {
            $( "#draggable" ).draggable();
            $( "#droppable" ).droppable({
               drop: function( event, ui ) {
                  $( this ).addClass( "ui-state-highlight" ).find( "p" ).html( "Dropped!" );
         #draggable { width: 100px; height: 100px; 
            padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
         #droppable { width: 150px; height: 150px; 
            padding: 0.5em; float: left; margin: 10px; }
      <div id = "draggable" class = "ui-widget-content">

      <div id = "droppable" class = "ui-widget-header">
         <p style = "background-color: aquamarine;height: 50;">Drop here</p>

This will produce following result −