title: How to execute a function when an element is drag and dropped
body: <p>I have a sorta-basic jquery/javascript question.</p>
  
  <p><strong>The code below will create objects which can be dragged and dropped. If you click on an object, it will display the ID of the "next" object.</strong></p>
  
  <p><strong>I wish to return this value (of the next object's ID) when the object is first "grabbed" (picked up without deliberately clicking) and then return the ID of the "next" object where it is placed.</strong></p>
  
  <p><em>Ideally, if the ID of the location it is grabbed is equal to the location where it is placed, it should not return any ID.</em></p>
  
  <p>The Jquery &amp; Javascript</p>
  
  <pre><code>$(function() {
      $( "#sortable" ).sortable();
      $( "#sortable" ).disableSelection();
  });
  
  $("li").live("click",function(e) {
      document.getElementById("result").innerHTML=($(this).next("li").attr('id'))
  });
  </code></pre>
  
  <p>The CSS:</p>
  
  <pre><code>#sortable { list-style-type: none; margin: 0; padding: 0; }
  #sortable li { margin: 3px 3px 3px 0; padding: 1px; float: left; width: 100px; height: 90px; font-size: 4em; text-align: center; }
  &lt;/style&gt;
  </code></pre>
  
  <p>The HTML:</p>
  
  <pre><code>&lt;div class="container"&gt;
  
  &lt;ul id="sortable"&gt;
      &lt;li id="li1" class="ui-state-default"&gt;1&lt;/li&gt;
      &lt;li id="li2" class="ui-state-default"&gt;2&lt;/li&gt;
      &lt;li id="li3" class="ui-state-default"&gt;3&lt;/li&gt;
      &lt;li id="li4" class="ui-state-default"&gt;4&lt;/li&gt;
      &lt;li id="li5" class="ui-state-default"&gt;5&lt;/li&gt;
      &lt;li id="li6" class="ui-state-default"&gt;6&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;/div&gt;
  
  &lt;br&gt;&lt;div id="result"&gt;Result Placed Here&lt;/div&gt;
  </code></pre>
  
  <p><strong>I don't even know where to start because I do not know how to run the function without it being clicked (without grabbing).</strong></p>
  
  <p>Any help is greatly appreciated,</p>
  
  <p>Taylor</p>
  
  <p>A JSfiddle can be found here:
  <a href="http://jsfiddle.net/TSM_mac/uuHsg/4/" rel="nofollow">http://jsfiddle.net/TSM_mac/uuHsg/4/</a></p>