JQuery Append()

jQuery append() method is used to insert the specified content at the last (at the end) of the selected elements in the jQuery collection

  • .append() puts data inside an element at last index.
  • .prepend() puts the prepending element at first index.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery append()</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>
<script>
$(document).ready(function() {
  $("#button").click(function() {
     $("p").append(" Saarthak!");
  });
});
</script>
</head>
<body>
 <p>Hello</p>
 <button style="margin:0 0 10px 0" class="btn" id="button">Click here</button><br />
 </body>
</html>