JQuery Appendto()

jQuery append() and appendTo() both methods is used to add specified content at the end of the selected elements. The major difference is in the syntax.

append() Syntax:


appendTo() Syntax:

$("<div class='box'>content</div>).appendTo('.box');

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery appendTo()</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
$(document).ready(function() {
  $("#button").click(function() {
     $("<span><strong>I'm coming from appendTo() method. </strong></span>").appendTo("p");
 <p>This is first paragraph. </p>
 <button style="margin:0 0 10px 0" class="btn" id="button">Click here</button><br />