$prepend $append $before $after

by mtambulut

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<a id="button" href="javascript:void(0);">Click to trigger</a>
<div id="schDisplay">
  Parent Div
</div>

JavaScript

jQuery(document).ready(function() {

  lastSlide = 0;

  jQuery('#button').click(function() {

    if (!($("#col" + lastSlide).length)) {
      $('#schDisplay').append('<div id="col' + (lastSlide) + '">child div with name col' + lastSlide + '</div>');
										  //append
                      //after
                      //before
      // COMMENT OUT this line to keep the value of lastSlide the same
      lastSlide++;
    }

  });


});