how to create dynamic div in jquery and append a label and div in a div

how to create dynamic div in jQuery and append a lebel and div in that div?

Hello everyone, I am going to  share the code sample for 
["how to create dynamic div in jquery and append a label and div in a div"]

Table of Contents

I . The parent div which contain the id is equal to chartRow.
II. jQuery code for creat daynamic div as per your requirements

Step 1.


<div class="panel-body">
    <div class="row" id="chartRow">
        <div class="usage-chart-1 col-lg-2 col-md-3 col-sm-4 col-xs-12 text-center"></div>
    </div>
</div>

Step 2.


<script type="text/javascript">
    $(document).ready(function () {
        creatDaynamicDiv();
    });

    function creatDaynamicDiv() {
        $("<div />", { "class": "market-donut cl", id: "alertChart" })
       .append($("<label />", { "class": "chart-title", id: "lblTitle" }))
       .append($("<div />", { id: "altDataChart" + key }))
       .append($("<label />", { "class": "fnt per-no-count", id: "lblPercent" }))
       .appendTo("#chartRow");
    }

</script>


ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^