title: jQuery sortable doesn't work with dynamically added divs
body: <p>I created a button that adds dynamically <code>divs</code> with elements inside. I want to use jQuery <code>.sortable()</code> to change the order of <code>divs</code> but for some reason it doesn't correctly.</p>
  
  <p>My code: <a href="https://jsfiddle.net/t5o1npd4/" rel="nofollow noreferrer">https://jsfiddle.net/t5o1npd4/</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    //Create button
    $(document).on('click', '#add', function() {
      var $skill1 = '&lt;select&gt;&lt;option disabled selected hidden&gt;Select One&lt;/option&gt;&lt;/select&gt;';
  
      $('&lt;div class="myClass"&gt;&lt;/div&gt;').appendTo('#area').append($skill1);
    });
  });
  
  //Why not works the sortable to dynamically added divs??
  $("#area").sortable({
    appendTo: "parent",
    helper: "clone",
    handle: ".myClass",
    stop: function(ui, event) {
      var id = event.item.index();
    }
  }).disableSelection();</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.myClass {
    padding: 5px;
    padding-right: 10px;
    border: 1px solid #909090;
    border-bottom: none;
    background-color: #cccccc;
  }
  
  .myClass:last-child {
    border-bottom: 1px solid #909090;
  }
  
  #area input[type="text"] {
    display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://code.jquery.com/jquery-1.12.4.js"&gt;&lt;/script&gt;
  &lt;script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"&gt;&lt;/script&gt;
  
  &lt;button id="add"&gt;&lt;b style="font-size:14px;"&gt;+&lt;/b&gt; Add&lt;/button&gt;
  
  &lt;div id="area"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>