how to append html in jquery?

Today, We want to share with you how to append html in jquery?.In this post we will show you document getelementbyid demo innerhtml append, hear for jquery .html() vs .append() we will give you demo and example for implement.In this post, we will learn about Append PHP HTML code using jQuery AJAX with an example.

jQuery append() Method

Insert content at the end of all

elements:

Example 1: append HTML Code

$("button").click(function(){
  $("p").append("<b>Appended text</b>");
});

Simple jQuery append() Method with Example

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Inserting HTML Contents At the End of the Elements in jQuery - www.pakainfo.com</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){

    $("p").append(' <a href="#">read more...</a>');
    
    $("button").click(function(){
       $("#container").append("This is demo text.");
    });
});
</script>
</head>
<body>
    <button type="button">Insert Text</button>
    <div id="container">
        <p>Tamilrockers is a torrent website that is immensely popular among south Indian movie fans. It is a desi version of the internationally notorious Pirate Bay from where one can download mostly South Indian movies and other content for free via a torrent client.</p>
        <p>Tamil Rockers. From Wikipedia, the free encyclopedia. Jump to navigation Jump to search. BitTorrent website. Tamil Rockers. Tamilrockers logo.jpg.</p>
    </div>
</body>
</html>

First declare

var html = "";
html += "<span class="Tamilrockers"> Welcome to  Tamilrockers new link</span>";
html += "<p class="pRed">Second Content</p>";
$(this).html(html); 

style.css
css file define

.Tamilrockers
{
  background-color: black;
}
.pRed
{
  background-color: red;
}

I hope you get an idea about jquery prepend.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.