UncleCoder.com

UncleCoder.com

Free programming examples and instructions

jQuery appent to a div

Code and demo for how to add extra html tags in to a div through jQuery

by Athil


Posted on 13 May 2017 Category: jQuery Views: 968

Edited on 06 Aug 2017


DEMO

Hi, Here I am going to show how to add extra HTML tags to a div(append HTML tags to div) through jQuery.

 $("#divid").append("<h1>Heading appended</h1>");

 

This is the code for append HTML tags heading to a div with id 'divid'.

FULL CODE

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Demo For jQuery apend to a div</title>
</head>
<body>
<script type="text/javascript" src="js/jquery.min.js" ></script>
    <h1>Demo For jQuery apend to a div </h1>
     
     <div id="divid" >My div</div>
     
     <button id="btnAdd" onclick="appendHeading();"> append heading to div</button>
     <script>
     function appendHeading()
     {
         $("#divid").append("<h1>Heading appended</h1>");
     }
     </script>
</body>
</html>


Leave a Comment:


Advertisement