$prepend $append $before $after
by mtambulut
HTML
<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').prepend('<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++;
}
});
});