Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, <strong><em>never</em></strong> use IDs that begin with a number or a symbol. According to this <a href="https://stackoverflow.com/questions/70579/what-are-valid-values-for-the-id-attribute-in-html#answer-79022">solution</a>:</p> <blockquote> <p>ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").</p> </blockquote> <hr> <p>Now let's clean up some of your code. For your current situation, I recommend using <a href="http://jqueryui.com/draggable/" rel="nofollow noreferrer"><code>.draggable()</code></a> and <a href="http://jqueryui.com/droppable/" rel="nofollow noreferrer"><code>.droppable()</code></a>.</p> <p>I started from scratch, but kept the <code>draggable</code> &amp; <code>droppable</code> options used in your <a href="http://jsfiddle.net/kvVkT/" rel="nofollow noreferrer">jsfiddle</a>. Here is what I came up with (feel free to change any aspect of it):</p> <p><strong><em>DEMO:</em></strong> <a href="http://jsfiddle.net/dirtyd77/Y8dLz/" rel="nofollow noreferrer">http://jsfiddle.net/dirtyd77/Y8dLz/</a> <br/> <a href="http://fiddle.jshell.net/dirtyd77/Y8dLz/show/" rel="nofollow noreferrer">http://fiddle.jshell.net/dirtyd77/Y8dLz/show/</a></p> <h3>JAVASCRIPT:</h3> <pre><code>$(function () { $('#container div').draggable({ containment: "#container", helper: 'clone', snap: true, snapMode: 'inner', snapTolerance: 32, revert: 'invalid' }); $('#container div').droppable({ hoverClass: 'ui-state-highlight', drop: function (event, ui) { var _drop = $(this), _drag = $(ui.draggable), _dropChildren = _drop.children(), //original drop children _dragChilden = _drag.children(); //original drag children if(_dropChildren.length &gt; 0){ _dropChildren.appendTo(_drag); } _dragChilden.appendTo(_drop); } }); }); </code></pre> <h3>HTML:</h3> <pre><code>&lt;div id="container"&gt; &lt;div&gt; &lt;a href="#somelink1" class="link1"&gt;Link 1&lt;/a&gt; &lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt; &lt;a href="#somelink2" class="link2"&gt;Link 2&lt;/a&gt; &lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt; &lt;a href="#somelink3" class="link3"&gt;Link 3&lt;/a&gt; &lt;/div&gt; &lt;div&gt; &lt;a href="#somelink1" class="link1"&gt;Link 4&lt;/a&gt; &lt;a href="#somelink3" class="link3"&gt;Link 5&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <h3>CSS:</h3> <pre><code>div:not(#container) { border:1px solid orange; } #container { padding:20px; margin:10px; float: left; /* needed for containment option */ width: 336px; height: auto; border:1px solid green; } #container div { margin: 4px; padding: 0px; float: left; width: 100px; height: 90px; text-align: center; } .link1{ color: purple; } .link2{ color: red; } .link3{ color: green; } </code></pre> <p>I hope this is what you're looking for! Please let me know if you need any further explanation or have any additional questions! Happy coding!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload