title: jQuery insert after the last element
body: <p>I want to add elements after the last one.
  My current code</p>
  
  <pre><code>&lt;div class="find"&gt;&lt;div id="FirstElement"&gt; /*First element loaded first */ &lt;/div&gt;&lt;div&gt;
  
  $('#AddNextElement' + id).click(function (e) {
     $('&lt;div id="NextElement' + id +'"&gt;' + /*Add after the last element*/ + '&lt;/div&gt;').insertAfter($("#FirstElement"));
  }
  </code></pre>
  
  <p>Current it adds only it after the first element:</p>
  
  <blockquote>
    <p>1
    4
    3
    2</p>
  </blockquote>
  
  <p>I want it to add after the last element every time:</p>
  
  <blockquote>
    <p>1
    2
    3
    4</p>
  </blockquote>
  
  <p>I've followed these links and I didn't find what I'm looking for:</p>
  
  <p><a href="https://stackoverflow.com/questions/17420281/jquery-insertafter-last-item">jQuery insertAfter last item</a></p>
  
  <p><a href="https://stackoverflow.com/questions/12161678/insertafter-specific-element-based-on-id">insertAfter specific element based on ID</a></p>
  
  <p><a href="https://stackoverflow.com/questions/2244605/jquery-add-element-after-another-element">jQuery: Add element after another element</a></p>
  
  <p>Thank you in advance!.</p>
  
  <p><strong>How I fixed it:</strong></p>
  
  <pre><code>$('#AddNextElement' + id).click(function (e) {
     $('&lt;div id="NextElement"' + id +'&gt;' + /*Add after the last element*/ + '&lt;/div&gt;').insertAfter($("#FirstElement").parent().find('.Finder').last());
  }
  </code></pre>
  
  <p><em>I found the .parent().find('.find').last(); then insert after the last</em></p>