title: jquery swap or move elements between 3 or more divs
body: <p>My script:</p>
  
  <pre><code>$(function () {
       initSwap();
  
       function initSwap() {
           initDroppable($(".dropdiv img,.dragdiv img"));
           initDraggable($(".dragdiv img,.dropdiv img"));
       }
  
       function initDraggable($elements) {
           $elements.draggable({
               appendTo: "body",
               tolerance: "pointer",
               helper: "clone",
               revert: "invalid"
           });
       }
  
       function initDroppable($elements) {
           $elements.droppable({
               appendTo: "body",
               activeClass: "ui-state-default",
               hoverClass: "ui-drop-hover",
               accept: ":not(.ui-sortable-helper)",
  
               over: function (event, ui) {
                   var $this = $(this);
               },
               drop: function (event, ui) {
                   var draggableId = ui.draggable.attr("id");
                   var draggablePlace = ui.draggable.attr("place");
  
                   var droppableId = $(this).attr("id");
                   var droppablePlace = $(this).attr("place");
  
                   var $this = $(this);
                   var linew1 = $(this).after(ui.draggable.clone());
                   var linew2 = $(ui.draggable).after($(this).clone());
  
                   $(ui.draggable).remove();
                   $(this).remove();
                   initSwap();
               }
           });
       }
   });
  </code></pre>
  
  <p>I made a jsFiddle: <a href="http://jsfiddle.net/kehator/7bZrV/2/" rel="nofollow">http://jsfiddle.net/kehator/7bZrV/23/</a></p>
  
  <p>It works almost perfect, but I need one more thing to do with 
  <code>&lt;div id="container" class="container"&gt;</code></p>
  
  <p>I would like to store the elements of the container so that the boxes may be empty, and replacement parts were made only after moving one element to another</p>
  
  <p><a href="http://i.stack.imgur.com/V5BgL.jpg" rel="nofollow">http://i.stack.imgur.com/V5BgL.jpg</a></p>