jQuery insertAfter vs. .after vs. .appendTo vs. .append
jQuery insertAfter vs. .after vs. .appendTo vs. .append
HTML
<div>div</div>
<thing>thing</thing>
<section>section</section>
<br/>
<div class="1">div1</div>
<thing class="1">thing1</thing>
<section class="1">section1</section>
<br/>
<div class="2">div2</div>
<thing class="2">thing2</thing>
<section class="2">section2</section>
<br/>
<div class="3">div3</div>
<thing class="3">thing3</thing>
<section class="3">section3</section>
<br/>
<div class="4">div4</div>
<thing class="4">thing4</thing>
<section class="4">section4</section>
JavaScript
// Insert every element in the set of matched elements after the target.
$('div.1').insertAfter('thing.1');
// Insert content, specified by the parameter, after each element in the set of matched elements.
$('div.2').after('<p>thing.2<p>');
// Insert every element in the set of matched elements to the end of the target.
$('div.3').appendTo('thing.3');
// Insert content, specified by the parameter, to the end of each element in the set of matched elements.
$('div.4').append('thing.4');