.append()
Insert content, specified by the parameter, to the end of each element in the set of matched elements..appendTo()
is same task
<h2>Greetings</h2>
<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
</div>
$( ".inner" ).append( "<p>Test</p>" );
// $( "<p>Test</p>" ).appendTo( ".inner" ); // same
<h2>Greetings</h2>
<div class="container">
<div class="inner"> <!-- target -->
Hello
<p>Test</p> <!-- new element -->
</div>
<div class="inner"> <!-- target -->
Goodbye
<p>Test</p> <!-- new element -->
</div>
</div>
.prepend()
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements..prependTo()
is same task
$( ".inner" ).prepend( "<p>Test</p>" );
// $( "<p>Test</p>" ).prependTo( ".inner" ); // same
<h2>Greetings</h2>
<div class="container">
<div class="inner"> <!-- target -->
Hello
<p>Test</p> <!-- new element -->
</div>
<div class="inner"> <!-- target -->
Goodbye
<p>Test</p> <!-- new element -->
</div>
</div>
Ref: