If you want to add HTML as is, just use the jQuery append function. For example:
$('body').append(' <div id="test">\ <h1>This is the test</h1>\ <p>Hello, just a test</p>\ <a href="www.test.com">Click me</a>\ <a href="www.test.com">Click me again</a>\ </div>');
Change the selector from the body to another DOM element / selector according to your requirements.
Or, if you already have a div element with the identifier "test" in the document, you can set the content using the html () function, as shown below:
$("#test").html('<h1>This is the test</h1>\ <p>Hello, just a test</p>\ <a href="www.test.com">Click me</a>\ <a href="www.test.com">Click me again</a>');
Technowise
source share