Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Droppable in jQuery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 128
    Comment on it

    The Droppable function can be used in JqueryUI to enable dropable functionality on a DOM element. In the example below using drop-able function we can drag an element and drop it to another container.

    Example code:

    <!doctype html>
    <html lang="en">
    <head>
      <title>jQuery UI Droppable </title>
      <style>
      #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; }
      </style>
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
      <script>
      $( function() {
        $( "#draggable" ).draggable();
        $( "#droppable" ).droppable({
           drop: function( event, ui ) {
            $( this )
              .find( "p" )
              .html( "Dropped!" )
             $( "#droppable" ).css( "background-color", "green");
              $( "#draggable" ).html( "");
                
          }
        });
      } );
      </script>
    </head>
    <body>
     
    <div id="draggable" style="background-color: #03a9f4;">
      <p>Drag me </p>
    </div>
    
    <div id="droppable"style="background-color: #ececec;">
      <p>Drop here</p>
    </div>
     
     
    </body>
    </html>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: